Closed F1sn1k closed 8 years ago
Yes, you can. You need to move those has_role?
checks inside the procs for role
blocks.
Something like this:
role :admin, proc { |user| user.has_role? :admin } do
# admin permissions
end
role :manager, proc { |user| user.manager? } do
# manager permissions
end
and so on. Please note that AccessGranted doesn't have can :manage, :all
, so your permissions need to be explicit.
@pokonski Thank for the answer.
Is there something like cancan's load_and_authorize_resource
and also skip ex: skip_load_and_authorize_resource only: :create
?
There isn't at the moment, but I consider adding authorize_resource
. Loading should not be AG's responsibility. I'm avoiding building a collosus like CanCan and keeping it simple
Thanks @pokonski . Great job btw
Glad you like it! :) I'm gonna close this one, if you find any other problems, let's do that in a new issue :+1:
First Congratulation on your work.
In our application One admin can have multiple roles as listed below. We use
role_model
gem.Roles are defined in
admin.rb
roles :account_manager, :customer_support, :data_entry, :sales_rep, :advertising_rep, :management, :tech_support, :super_admin
It works fine with
cancan
but I liked your gem a lot. Can thisability.rb of cancan
be replaced inaccess_policy.rb
. If yes please help me out