implantação da fase 2 e 3

This commit is contained in:
2026-06-10 20:12:20 -03:00
parent d37237ead2
commit 472484798f
33 changed files with 2915 additions and 430 deletions

View File

@@ -0,0 +1,46 @@
# app/policies/user_policy.rb
class UserPolicy < ApplicationPolicy
def index?
admin_ou_gerente?
end
def show?
admin? || record == user
end
def create?
admin?
end
def new?
create?
end
def update?
admin? || record == user
end
def edit?
update?
end
def destroy?
admin? && record != user
end
def toggle_ativo?
admin?
end
class Scope < Scope
def resolve
if user.admin?
scope.all
elsif user.gerente?
scope.where.not(role: :admin)
else
scope.where(id: user.id)
end
end
end
end