Files
plottservice/app/policies/job_policy.rb
2024-10-02 13:51:15 +02:00

24 lines
564 B
Ruby

class JobPolicy < ApplicationPolicy
skip_pre_check :allow_admins, only: :cancel?
def cancel?
record.open? && (user == record.customer || user.operator? || user.admin?)
end
# See https://actionpolicy.evilmartians.io/#/writing_policies
#
#
# def update?
# # here we can access our context and record
# user.admin? || (user.id == record.user_id)
# end
# Scoping
# See https://actionpolicy.evilmartians.io/#/scoping
#
# relation_scope do |relation|
# next relation if user.admin?
# relation.where(user: user)
# end
end