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
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)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.