Skip to content

Commit

Permalink
Inline controller's permitted_attributes method
Browse files Browse the repository at this point in the history
Fixes thoughtbot#417

Problem:

If users include the Pundit gem on an Administrate controller,
the controller attempts to call the `permitted_attributes` method
defined by pundit instedad of the one defined by Administrate.

Because these methods take different arguments,
this results in an `ArgumentError` for the user.

Solution:

Inline the `permitted_attributes` method
to avoid the method name collision.

This narrows the public API a bit, but that's alright.
The user can accomplish all of the removed functionality by overriding
the parent `resource_params` method.
  • Loading branch information
c-lliope authored and Envek committed Oct 21, 2016
1 parent 73d4d55 commit aec23b9
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions app/controllers/administrate/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,7 @@ def find_resource(param)
end

def resource_params
params.require(resource_name).permit(*permitted_attributes)
end

def permitted_attributes
dashboard.permitted_attributes
params.require(resource_name).permit(dashboard.permitted_attributes)
end

delegate :resource_class, :resource_name, :namespace, to: :resource_resolver
Expand Down

0 comments on commit aec23b9

Please sign in to comment.