Class: UserPolicy
- Inherits:
-
ApplicationPolicy
- Object
- ApplicationPolicy
- UserPolicy
- Defined in:
- lib/generators/rockstart/pundit/templates/app/policies/user_policy.rb
Overview
Policy for updating profiles, provided by rockstart
Defined Under Namespace
Classes: Scope
Instance Attribute Summary
Attributes inherited from ApplicationPolicy
Instance Method Summary collapse
- #destroy? ⇒ Boolean
- #permitted_attributes ⇒ Object
-
#update? ⇒ Boolean
def create? false end.
Methods inherited from ApplicationPolicy
#create?, #edit?, #index?, #initialize, #new?, #permitted_attributes_for_create, #permitted_attributes_for_update, #show?
Constructor Details
This class inherits a constructor from ApplicationPolicy
Instance Method Details
#destroy? ⇒ Boolean
21 22 23 24 |
# File 'lib/generators/rockstart/pundit/templates/app/policies/user_policy.rb', line 21 def destroy? # Prevent admins from destroying themselves current_user? && !record.admin? end |
#permitted_attributes ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/generators/rockstart/pundit/templates/app/policies/user_policy.rb', line 26 def permitted_attributes if current_user? # Allow a user to update their own details %i[name] else [] end end |
#update? ⇒ Boolean
def create?
false
end
17 18 19 |
# File 'lib/generators/rockstart/pundit/templates/app/policies/user_policy.rb', line 17 def update? current_user? end |