diff --git a/app/controllers/spree/admin/payment_methods_controller_decorator.rb b/app/controllers/spree/admin/payment_methods_controller_decorator.rb new file mode 100644 index 0000000000..d1d367fc47 --- /dev/null +++ b/app/controllers/spree/admin/payment_methods_controller_decorator.rb @@ -0,0 +1,14 @@ +Spree::Admin::PaymentMethodsController.class_eval do + # Only show payment methods that user has access to. + # ! Redundant code copied from Spree::Admin::ResourceController with two added lines + def collection + return parent.send(controller_name) if parent_data.present? + if model_class.respond_to?(:accessible_by) && !current_ability.has_block?(params[:action], model_class) + model_class.accessible_by(current_ability, action). + managed_by(spree_current_user) # this line added + else + model_class.scoped. + managed_by(spree_current_user) # this line added + end + end +end \ No newline at end of file