Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"additional_collection" attribute does't work with Rails 4 by default #204

Open
tanelj opened this issue Apr 1, 2015 · 1 comment
Open

Comments

@tanelj
Copy link
Contributor

tanelj commented Apr 1, 2015

It seems that :additional_collection attribute is ignored in Rails 4 (4.2.1) or when :strong_parameters is set to true. Example:

filter_resource_access context: :users, additional_collection: [:search]

Accessing to /users/search tries to load object a raises error:

filter_access_to tried to find User from params[:id] (nil), because attribute_check is enabled and @user isn't set, but failed: ActiveRecord::RecordNotFound: Couldn't find User with 'id'=

At the moment the line

no_attribute_check_actions = options[:strong_parameters] ? actions_from_option(options[:collection]).merge(actions_from_option([:create])) : collections

is:

no_attribute_check_actions = options[:strong_parameters] ? actions_from_option(options[:collection]).merge(actions_from_option([:create])) : collections

But it seems that correct one should be:

no_attribute_check_actions = options[:strong_parameters] ? collections.merge(actions_from_option([:create])) : collections

@zeiv - is that correct?

@zeiv
Copy link
Contributor

zeiv commented May 29, 2015

You are right, it should merge from the collections variable to pick up :additional_collection. Good catch!

zeiv added a commit to zeiv/declarative_authorization that referenced this issue May 29, 2015
Chocksy added a commit to NetsoftHoldings/declarative_authorization that referenced this issue Jul 15, 2015
t27duck pushed a commit to t27duck/declarative_authorization that referenced this issue May 10, 2016
urkle pushed a commit to NetsoftHoldings/declarative_authorization that referenced this issue Dec 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants