问题
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:
- You have not got the correct routes defined in your routes configuration file
- 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".
来源:https://stackoverflow.com/questions/19952066/undefined-local-variable-or-method-sign-out-path