问题描述:

I can't get the sign out button to function properly. I've added a test to the _header.html.erb partial that will add a link to show whether or not current_user is nil. After clicking the sign out link under the Account list item, it still shows that it is not nil. And it never shows the sign in link, so it always thinks there is a user logged in.

Can somebody take a look at this?

Here is a link to my repository:

https://github.com/davissean/sample_app

网友答案:

Try rake db:reset in the terminal and then restart the rails server

I had the same problem. Spent 6+ hrs rechecking code and testing. Everything checked out, but still never got it to work locally, so I pushed it to heroku... and it worked.

But the problem persisted in chapter 9, until I auto-populated the database, hence the db:reset

And, don't forget to run rake db:test:prepare or your tests will fail.

网友答案:

The problem seems to be that

https://github.com/davissean/sample_app/blob/master/app/helpers/sessions_helper.rb, line 25

sets a local variable to nil rather than @current_user.

相关阅读:
Top