Rails tutorial 3.2 capítulo 8, no puedo cerrar sesión para destruir current_user en la sesión

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

preguntado el 22 de mayo de 12 a las 14:05

2 Respuestas

Trata 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.

Respondido 18 ago 12, 15:08

I'm not sure what was the problem with my version, but I asked a friend a while back to test it on his machine and he said that it worked fine. So I cloned the repository again and it worked.. fine. I'm pretty sure I had tried db:reset because it says to do that in the tutorial somewhere. I dunno. - no_shitashi

El problema parece ser que

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

sets a local variable to nil rather than @current_user.

Respondido 19 ago 12, 08:08

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.