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

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -