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

nested controllers and strong parameters. #209

Open
urkle opened this issue Jun 12, 2015 · 0 comments
Open

nested controllers and strong parameters. #209

urkle opened this issue Jun 12, 2015 · 0 comments

Comments

@urkle
Copy link
Contributor

urkle commented Jun 12, 2015

So, I have a nested controller in a project I'm converting to rails 4.2. using the head master. I have a before_filter configured to load up the model for the create action.. However.. due to the ordering of the before filters, that gets run AFTER the permissions are being checked.

  filter_resource_access :nested_in => :commentable
  before_filter :new_comment_from_params, :only => :create
```ruby

And I can't put it before, as it relies on Decl auth running the load_parent_controller_object / load_commentable
```ruby
  def load_commentable
    @commentable = find_polymorphic
  end

  def new_comment_from_params
    @comment = @commentable.comments.build (comment_params).merge(author: current_user)
  end

This creates a lovely catch-22 problem in the code. IMHO in the "Strong parameters" case decl auth should handle the :create before filter and either.
only check for new_{model}_from_params OR have a default implementation that expects {model}_params to handle the strong parameters logic.

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

1 participant