Ruby on Rails Monday, January 23, 2012

Hai!

I tried

session[:user_id].freeze

but I got same problem


At-last I got one solution.

def login
.
.
if @user && @user.password == params[:user][:password]
session[:user_info_id] = session[:user_id] = @user.id
session[:user_info_id].freeze
redirect_to :controller => "second_controller", :action => "index"
end
end

second_controller.rb

def index
if session[:user_info_id] != nil
session[:user_id] = session[:user_info_id]
logger.info" The user id is not null"
else
logger.info" The user id is null"
end
end

===========>result

The user id is not null
The user id is not null
The user id is not null
The user id is not null
The user id is not null
The user id is not null
The user id is not null
The user id is not null
The user id is not null
The user id is not null
The user id is not null
The user id is not null

Thanks for ruby-forum
by:
bdeveloper01

--
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@googlegroups.com.
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.

No comments:

Post a Comment