ruby on rails - Rails5 - Undefined local variable but it's global -
i getting following error in rails:
undefined local variable or method `current_user' #<usercontroller:0x0000000458d708> did mean? @current_user the code fragment corresponding error is:
authorize @current_user as can see, mean @current_user error message suggests, , use @current_user error message suggests. why rails thinking mean local unexisting variable when expect global? authorize method pundit.
i added print statement verify if global variable exists, , following code prints out valid user:
p @current_user authorize @current_user
to use pundit, must define current_user (or pundit_user): https://github.com/elabs/pundit/blob/master/lib/pundit.rb#l270
when authorize @current_user, assuring current_user can perform actions on @current_user using userpolicy.
Comments
Post a Comment