ruby on rails - Undefined method `admin?' for nil:NilClass -
i have restricted 1 page other users if not logged in , visit page, error in line redirect_to '/' unless current_user.admin?
but if logged in , visit page,it works fine. in application
controller
class applicationcontroller < actioncontroller::base def require_admin redirect_to '/' unless current_user.admin? end
please can tell me why error coming in advance!!!
current_user.try(:admin?)
this check if current user present
Comments
Post a Comment