Reputation: 10208
The title is very explanatory.
How can I integrate active_admin gem with cancan? I need administrative roles.
Thanks
Upvotes: 1
Views: 3723
Reputation: 5206
Nowadays there is a gem that do the work: https://github.com/11factory/activeadmin-cancan
Upvotes: 0
Reputation: 1974
Following link is also helpful to set cancan with activeadmin.
https://github.com/gregbell/active_admin/wiki/How-to-work-with-cancan
Upvotes: 0
Reputation: 21549
for a simple case, assuming there are 2 roles: normal_user , admin,
if you just want to "admin" to access "/admin" (activeadmin's default namespace), while "normal_user" can not, I suggest you take a look a hook method:
# config/initializers/active_admin.rb
config.before_filter :check_user_role
# define this method in applicaton_controller.rb
def check_user_role
redirect_to root_path unless current_user.role == "admin"
end
Upvotes: 1