Reputation: 4728
I have installed the Activ Admin gem but not sure it will be of any help. I have some pages which I want to hide from being seen by anonymous and some from logged in users too. How can I do it ?
I am sure there must be ACL gems in RoR but I am not sure which is the standard and preferred way to do it ? any help ? Thanks
Upvotes: 0
Views: 981
Reputation: 7303
I'm not familiar with Active Admin but,
assuming you already have a way of determining if a user is logged in (and you have a way to address the current_user
), you could simply do the following:
def admin_users_only
unless current_user.admin? redirect_to "wherever you want to redirect to"
end
before_filter :admin_users_only, only: [:index, :or, :any, :other]
(of course your user model needs an admin attribute)
Upvotes: 1