-
Notifications
You must be signed in to change notification settings - Fork 14
Open
Description
Currently, you can pass an :if option to the attribute directive. It would be helpful if this option could be a symbol of a method on the controller instead of a Proc. It would function like before_action on controllers and validate on models. Instead of passing the current controller/context into the proc, you'd just call the method on the controller (or maybe call it from 'within' the context of the controller so it can use private/protected methods, similar to before_action).
Example:
# config/initializers/strong_resources.rb
strong_resource :person do
attribute :age, :integer, if: :admin?
end
class PeopleController < ApplicationController
strong_resource :person
def admin?
current_user.admin?
end
endMetadata
Metadata
Assignees
Labels
No labels