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

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

Don't you want to nil out @current_user rather than @current_id ?

Fred

Don't you want to nil out @current_user rather than @current_id ?

Fred

good call fred! thanks pal, worked like a charm.