3 ms·
I tend to use the declarative gem: PublicKey.with_permissions_to(:write) and then define the scoping rules in the declarative auth file: authorization do r
by phamilton 15y ago
I tend to use the declarative gem:
PublicKey.with_permissions_to(:write)
and then define the scoping rules in the declarative auth file:
authorization do
role :user do
has_permission_on :public_keys do
to [:write, :read]
# user refers to the current_user when evaluating
if_attribute :user_id => is {user.id}
end
end
end
This is a bit more DRY, because you are abstract out the conditions of access. This is especially useful in situations where you have readonly access or other types of acl.