class UserController < ApplicationController
def home
# Following line throws error and session[:user] set by previous
action login is gone here.
$logme.info “Home session information: is #{session[:user].login}
and #{session[:user].firstname}”
redirect_to_stored_or_default :controller => “start”,:action =>
‘index’
end
trying to access also called from a Ajax request normally. If not,
they will be sent to “/user/home”.
def login
if session[:user]
render :partial => ‘shared/error_msg’, :object => “Invalid
Request”, :layout => true
return
end
return if generate_blank
if @user = User.authenticate(params[:user][:login],
params[:user][:password])
@user.logged_in_at = Time.now
session[:maps_cust_pref] = nil
save_option = params[:save_option][:save_option].to_i
generate_cookie_for_ticks
save_pref if save_option == 1
session[:user] = @user
session[:user].save
# printing session information works here, but as soon as we
redirect_to another page, all the session
# information is lost
$logme.info “From session information: is #{session[:user].login}
and #{session[:user].firstname}”
render :update do |page|
page.redirect_to(:controller => ‘user’,:action => ‘home’)
end
else
render :update do |page|
page.replace_html('errordiv',:partial => 'error',
:object => "<p
style=‘background:#d57068 ;margin:0px 200px 2px 0px; padding:2px 5px 2px
5px; color:#ffffff ;’>Invalid Login ID or Password
")
page.visual_effect :highlight, ‘errordiv’
end
end
end
end
I am doing nothing special here and yet i wonder why this happens?
It was working alright on 1.1.6 although.
gnufied
September 25, 2007, 10:29pm
2
On Sat, 2007-01-13 at 05:08 +0530, Hemant K. wrote:
render :partial => 'shared/error_msg', :object => "Invalid Request", :layout => true
page.redirect_to(:controller => 'user',:action => 'home')
end
I am doing nothing special here and yet i wonder why this happens?
It was working alright on 1.1.6 although.
Well in case, anyone is looking for exact error its here:
You have a nil object when you didn’t expect it!
The error occurred while evaluating nil.login
RAILS_ROOT: /home/gnufied/ubac_webfront/config/…
Application Trace | Framework Trace | Full Trace
#{RAILS_ROOT}/app/controllers/user_controller.rb:4:in home' /usr/local/bin/mongrel_rails:18:in
load’
/usr/local/bin/mongrel_rails:18
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.5.5848/lib/action_controller/base.rb:1092:in
send' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.5.5848/lib/action_controller/base.rb:1092:in
perform_action_without_filters’
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.5.5848/lib/action_controller/filters.rb:632:in
call_filter' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.5.5848/lib/action_controller/filters.rb:638:in
call_filter’
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.5.5848/lib/action_controller/filters.rb:438:in
call' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.5.5848/lib/action_controller/filters.rb:637:in
call_filter’
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.5.5848/lib/action_controller/filters.rb:619:in
perform_action_without_benchmark' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.5.5848/lib/action_controller/benchmarking.rb:66:in
perform_action_without_rescue’
/usr/local/lib/ruby/1.8/benchmark.rb:293:in measure' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.5.5848/lib/action_controller/benchmarking.rb:66:in
perform_action_without_rescue’
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.5.5848/lib/action_controller/rescue.rb:83:in
perform_action' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.5.5848/lib/action_controller/base.rb:427:in
send’
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.5.5848/lib/action_controller/base.rb:427:in
process_without_filters' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.5.5848/lib/action_controller/filters.rb:624:in
process_without_session_management_support’
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.5.5848/lib/action_controller/session_management.rb:114:in
process' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.5.5848/lib/action_controller/base.rb:330:in
process’
/usr/local/lib/ruby/gems/1.8/gems/rails-1.1.6.5848/lib/dispatcher.rb:41:in
dispatch' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0/lib/mongrel/rails.rb:78:in
process’
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0/lib/mongrel/rails.rb:76:in
synchronize' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0/lib/mongrel/rails.rb:76:in
process’
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0/lib/mongrel.rb:618:in
process_client' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0/lib/mongrel.rb:617:in
each’
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0/lib/mongrel.rb:617:in
process_client' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0/lib/mongrel.rb:736:in
run’
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0/lib/mongrel.rb:736:in
initialize' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0/lib/mongrel.rb:736:in
new’
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0/lib/mongrel.rb:736:in
run' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0/lib/mongrel.rb:720:in
initialize’
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0/lib/mongrel.rb:720:in
new' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0/lib/mongrel.rb:720:in
run’
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0/lib/mongrel/configurator.rb:271:in
run' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0/lib/mongrel/configurator.rb:270:in
each’
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0/lib/mongrel/configurator.rb:270:in
run' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0/bin/mongrel_rails:127:in
run’
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0/lib/mongrel/command.rb:211:in
run' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0/bin/mongrel_rails:243 #{RAILS_ROOT}/app/controllers/user_controller.rb:4:in
home’
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.5.5848/lib/action_controller/base.rb:1092:in
send' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.5.5848/lib/action_controller/base.rb:1092:in
perform_action_without_filters’
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.5.5848/lib/action_controller/filters.rb:632:in
call_filter' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.5.5848/lib/action_controller/filters.rb:638:in
call_filter’
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.5.5848/lib/action_controller/filters.rb:438:in
call' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.5.5848/lib/action_controller/filters.rb:637:in
call_filter’
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.5.5848/lib/action_controller/filters.rb:619:in
perform_action_without_benchmark' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.5.5848/lib/action_controller/benchmarking.rb:66:in
perform_action_without_rescue’
/usr/local/lib/ruby/1.8/benchmark.rb:293:in measure' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.5.5848/lib/action_controller/benchmarking.rb:66:in
perform_action_without_rescue’
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.5.5848/lib/action_controller/rescue.rb:83:in
perform_action' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.5.5848/lib/action_controller/base.rb:427:in
send’
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.5.5848/lib/action_controller/base.rb:427:in
process_without_filters' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.5.5848/lib/action_controller/filters.rb:624:in
process_without_session_management_support’
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.5.5848/lib/action_controller/session_management.rb:114:in
process' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.5.5848/lib/action_controller/base.rb:330:in
process’
/usr/local/lib/ruby/gems/1.8/gems/rails-1.1.6.5848/lib/dispatcher.rb:41:in
dispatch' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0/lib/mongrel/rails.rb:78:in
process’
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0/lib/mongrel/rails.rb:76:in
synchronize' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0/lib/mongrel/rails.rb:76:in
process’
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0/lib/mongrel.rb:618:in
process_client' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0/lib/mongrel.rb:617:in
each’
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0/lib/mongrel.rb:617:in
process_client' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0/lib/mongrel.rb:736:in
run’
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0/lib/mongrel.rb:736:in
initialize' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0/lib/mongrel.rb:736:in
new’
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0/lib/mongrel.rb:736:in
run' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0/lib/mongrel.rb:720:in
initialize’
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0/lib/mongrel.rb:720:in
new' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0/lib/mongrel.rb:720:in
run’
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0/lib/mongrel/configurator.rb:271:in
run' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0/lib/mongrel/configurator.rb:270:in
each’
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0/lib/mongrel/configurator.rb:270:in
run' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0/bin/mongrel_rails:127:in
run’
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0/lib/mongrel/command.rb:211:in
run' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0/bin/mongrel_rails:243 /usr/local/bin/mongrel_rails:18:in
load’
/usr/local/bin/mongrel_rails:18
Request
Parameters: None
flash: !map:ActionController::Flash::FlashHash {}
Response
Headers: {“cookie”=>[], “Cache-Control”=>“no-cache”}