undefined local variable or method `sign_out_path&

2019-07-24 23:17发布

问题:

I'm beginner in rails application. I have used devise gem to authentication purpose. when I log in its showing error: undefined local variable or method `sign_out_path'

How can I solve this problem?

回答1:

There could be two reasons for this:

  1. You have not got the correct routes defined in your routes configuration file
  2. You have used a path helper for an existing route but mistakenly used the wrong name

First run rake routes. Have a look through the output and see if you can see any routes beginning with "devise".

If you can see one called "destroy_user_session" then this is actually the name you need to use for your sign out link, and not "sign_out_path". In that case, go to the view where you have put your sign out link and replace the helper with "destroy_user_session_path".