Reputation: 163
I am trying to access a variable passed in when a user (using Devise) signs in or signs out.
So I have edited the Devise Sessions controller (/controllers/devise/sessions_controller.rb
) to setup a variable when a user logs in / out:
def create
@signed_in_token = "something"
However I now want to access this variable in /views/layouts/application.html.erb
. It doesn't seem to be showing up...
Upvotes: 1
Views: 346
Reputation: 1549
The problem there that this actions are use redirect_to
method after call. You can use flash
obejct to pass variable to next render.
def create
flash[:you_variable] ="test"
And than you can access it in view
<%= flash[:you_variable] %>
Upvotes: 1