Merrick Johnson
2008-Dec-21 22:43 UTC
help: session is deleted, but after the view is rendered
Scenario: user is logged in, they click the logout button, which fires the action method Sessions#destroy and the view. The problem i''m having is that even tho the session is deleted, the first go round it still displays logged in. If you refresh it then says not logged in. I am not sure how to even begin debugging this. thanks! Controller: class SessionsController < ApplicationController ... def destroy session[:user_id] = @current_id = nil end end Main layout: ... <% if @current_user %> Logged in as: <%= @current_user.login %> <em><%= link_to ''Logout'', session_path, :method => :delete %></em> <% else %> <em>Not logged in.</em> <%= link_to ''Login'', new_session_path %> <% end %> ... -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2008-Dec-21 23:08 UTC
Re: help: session is deleted, but after the view is rendered
On Dec 21, 10:43 pm, Merrick Johnson <rails-mailing-l...@andreas- s.net> wrote:> Scenario: > > user is logged in, they click the logout button, which fires the action > method Sessions#destroy and the view. The problem i''m having is that > even tho the session is deleted, the first go round it still displays > logged in. If you refresh it then says not logged in. I am not sure how > to even begin debugging this. thanks!> > Controller: > > class SessionsController < ApplicationController > ... > def destroy > session[:user_id] = @current_id = nilDon''t you want to nil out @current_user rather than @current_id ? Fred> end > end > > Main layout: > > ... > <% if @current_user %> > Logged in as: <%= @current_user.login %> > <em><%= link_to ''Logout'', session_path, :method => :delete %></em> > <% else %> > <em>Not logged in.</em> > <%= link_to ''Login'', new_session_path %> > <% end %> > ... > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Merrick Johnson
2008-Dec-21 23:22 UTC
Re: help: session is deleted, but after the view is rendered
> Don''t you want to nil out @current_user rather than @current_id ? > > Fredgood call fred! thanks pal, worked like a charm. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---