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

Override the inferred record class at the controller level #32

Closed
brendon opened this issue Jul 17, 2018 · 2 comments
Closed

Override the inferred record class at the controller level #32

brendon opened this issue Jul 17, 2018 · 2 comments

Comments

@brendon
Copy link
Contributor

brendon commented Jul 17, 2018

Would you consider adding the functionality where one could define the model class at the controller level? Currently I have to do something like this:

class Admin::ActivitiesController < Global::AdminController
  
  private

  def authorize!
    super PublicActivity::Activity
  end

  def allowed_to?(rule)
    super rule, PublicActivity::Activity
  end
end

Perhaps we could define this class at a class level once?

@palkan
Copy link
Owner

palkan commented Jul 17, 2018

This functionality has been already added in Scoping PR.

The method is called implicit_authorization_target. In your case it would be:

class Admin::ActivitiesController < Global::AdminController
  def implicit_authorization_target
    PublicActivity::Activity
  end
end

@brendon
Copy link
Contributor Author

brendon commented Jul 17, 2018

Thanks @palkan :) Good to know it's on the way :)

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