From 1bfb54f31053fd8097632fc60ea878a836dfbb28 Mon Sep 17 00:00:00 2001 From: David Cook Date: Fri, 23 Aug 2013 13:25:10 +1000 Subject: [PATCH] Refactor authorisation to play nice with Spree instead of patching it (thanks to Rohan's suggestions) --- .../spree/admin/base_controller_decorator.rb | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 app/controllers/spree/admin/base_controller_decorator.rb diff --git a/app/controllers/spree/admin/base_controller_decorator.rb b/app/controllers/spree/admin/base_controller_decorator.rb deleted file mode 100644 index 8e876513fa..0000000000 --- a/app/controllers/spree/admin/base_controller_decorator.rb +++ /dev/null @@ -1,14 +0,0 @@ -Spree::Admin::BaseController.class_eval do - # Override Spree method - # It's a shame Spree doesn't just let CanCan handle this in it's own way - def authorize_admin - if respond_to?(:model_class, true) && model_class - record = model_class - else - # this line changed to allow specificity for each non-resource controller (to be consistent with "authorize_resource :class => false", see https://github.com/ryanb/cancan/blob/60cf6a67ef59c0c9b63bc27ea0101125c4193ea6/lib/cancan/controller_resource.rb#L146) - record = self.class.to_s.sub("Controller", "").underscore.split('/').last.singularize.to_sym - end - authorize! :admin, record - authorize! action, record - end -end \ No newline at end of file