Class: ApplicationPolicy::Scope
- Inherits:
-
Scope
- Object
- Scope
- ApplicationPolicy::Scope
- Defined in:
- lib/generators/natural/install/templates/application_policy.rb
Instance Method Summary collapse
- #anon_user_scope ⇒ Object
-
#resolve ⇒ Object
It is recommended to use per-role scopes for Users # simply extend the resolve method with conditions for each “role” and the name of the scope they should call.
- #standard_user_scope ⇒ Object
Instance Method Details
#anon_user_scope ⇒ Object
19 20 21 22 |
# File 'lib/generators/natural/install/templates/application_policy.rb', line 19 def anon_user_scope scope # scope.public # e.g. only display public data end |
#resolve ⇒ Object
It is recommended to use per-role scopes for Users # simply extend the resolve method with conditions for each “role” and the name of the scope they should call.
6 7 8 9 10 11 12 |
# File 'lib/generators/natural/install/templates/application_policy.rb', line 6 def resolve if !user.is_a? User anon_user_scope else standard_user_scope end end |
#standard_user_scope ⇒ Object
14 15 16 17 |
# File 'lib/generators/natural/install/templates/application_policy.rb', line 14 def standard_user_scope scope # scope.where(user: user) # e.g. only show resources that belong to that user end |