When a user logout, the session is deleted, so I can’t use a
flash[:notice] stating that the user has been disconnected (and more…)
in my _header.rhtml view
<%= link_to ‘Logout’, logout_path %>
in my route.rb
map.logout ‘logout’, :controller => ‘session’, :action => ‘destroy’
in my session_controller.rb
def destroy
session.delete
cookies.delete :login_token
flash[:notice] = “You have been disconnected”
redirect_to home_path
end
in my application.rhtml layout
<% if flash[:notice] -%>
<%= flash[:notice] %>
<% end %>
when a session is deleted, it’ clears all variables… I thought I could
write a flash[notice] to be displayed, but it seems not to be the
case… any clue ?
thanks
kad
in my session_controller.rb
def destroy
session.delete
cookies.delete :login_token
flash[:notice] = “You have been disconnected”
redirect_to home_path
end
Can you set some new variable to be passed (make your own flash) - do
something like:
in my session_controller.rb
def destroy
session.delete
cookies.delete :login_token
flash[:notice] = “You have been disconnected”
@myflash = “You have been disconnected”
redirect_to home_path
end
But then you’d have to delete the @myflash variable once you
redirect_to_home_path
Dustin A. wrote:
in my session_controller.rb
def destroy
session.delete
cookies.delete :login_token
flash[:notice] = “You have been disconnected”
redirect_to home_path
end
Can you set some new variable to be passed (make your own flash) - do
something like:
it should be a session variable…
in my session_controller.rb
def destroy
session.delete
cookies.delete :login_token
flash[:notice] = “You have been disconnected”
@myflash = “You have been disconnected”
redirect_to home_path
end
But then you’d have to delete the @myflash variable once you
redirect_to_home_path
once I am redirected the @myflash variable doesn’t exist anymore (?) a
session variable will carry the message… but a flash[] is a session
variable too… and it’s = nil after redirected , don’t understand why
…
my exampel is not completly written from scratch… it’s taken from the
‘beast’ example, and it’s doesn’t run well too in this example… I am
not wrong alone …
RSL ___ wrote:
Why not just nullify the proper session variables instead of emptying
out
the whole thing?
RSL
too smart… rethinking a little bit => no need for session.delete only
cookie :login.token need to be deleted to avoid an auto login again…
thnaks !
Why not just nullify the proper session variables instead of emptying
out
the whole thing?
RSL
you can simple type
reset_session
and all will be reseted as first time user was entered to site.
On Aug 19, 11:17 am, Kad K. [email protected]