hi Michael ,
this full trace of the error below.i am new in ROR ,so can you tell me how
to set session in ROR?
and if set session is coming null then can set it?

i give you the brief of my project :-
in my project the main rhtml is main_bk_layout.rhtml into which the one
user_login.rhtml is called.
but when i hitting url on local host it will give the error for nil session
for user.

full error trace:-

Processing LoginController#user_login (for 127.0.0.1 at 2011-12-16
13:40:23) [GET]
Rendering template within layouts/main_bk_layout
Rendering login/user_login

ActionView::TemplateError (You have a nil object when you didn't expect it!
You might have expected an instance of ActiveRecord::Base.
The error occurred while evaluating nil.[]) on line #61 of
app/views/layouts/main_bk_layout.rhtml:
58: <%if @session != nil%>
59: <table width="250" border="0" height="20"
align="right" cellspacing="0" cellpadding="0">
60: <%else%>
61: <%if @session['user'].first_name == "admin"%>
62: <table width="290" border="0" height="20"
align="right" cellspacing="0" cellpadding="0">
63: <%end%>
64: <%end%>

app/views/layouts/main_bk_layout.rhtml:61:in
`_run_rhtml_app47views47layouts47main_bk_layout46rhtml'
D:/Ruby187/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
D:/Ruby187/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
D:/Ruby187/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
D:/Ruby187/lib/ruby/1.8/webrick/server.rb:162:in `start'
D:/Ruby187/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
D:/Ruby187/lib/ruby/1.8/webrick/server.rb:95:in `start'
D:/Ruby187/lib/ruby/1.8/webrick/server.rb:92:in `each'
D:/Ruby187/lib/ruby/1.8/webrick/server.rb:92:in `start'
D:/Ruby187/lib/ruby/1.8/webrick/server.rb:23:in `start'
D:/Ruby187/lib/ruby/1.8/webrick/server.rb:82:in `start'
-e:2:in `load'
-e:2

Rendered rescues/_trace (46.9ms)
Rendered rescues/_request_and_response (15.6ms)
Rendering rescues/layout (internal_server_error)
[4;36;1mSQL (0.0ms) [0m [0;1mSET SQL_AUTO_IS_NULL=0 [0m
[4;35;1mCountry Load (0.0ms) [0m [0mSELECT * FROM `countries` [0m


Processing LoginController#user_login (for 127.0.0.1 at 2011-12-16
13:40:27) [GET]
Rendering template within layouts/main_bk_layout
Rendering login/user_login

ActionView::TemplateError (You have a nil object when you didn't expect it!
You might have expected an instance of ActiveRecord::Base.
The error occurred while evaluating nil.[]) on line #61 of
app/views/layouts/main_bk_layout.rhtml:
58: <%if @session != nil%>
59: <table width="250" border="0" height="20"
align="right" cellspacing="0" cellpadding="0">
60: <%else%>
61: <%if @session['user'].first_name == "admin"%>
62: <table width="290" border="0" height="20"
align="right" cellspacing="0" cellpadding="0">
63: <%end%>
64: <%end%>

app/views/layouts/main_bk_layout.rhtml:61:in
`_run_rhtml_app47views47layouts47main_bk_layout46rhtml'
D:/Ruby187/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
D:/Ruby187/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
D:/Ruby187/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
D:/Ruby187/lib/ruby/1.8/webrick/server.rb:162:in `start'
D:/Ruby187/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
D:/Ruby187/lib/ruby/1.8/webrick/server.rb:95:in `start'
D:/Ruby187/lib/ruby/1.8/webrick/server.rb:92:in `each'
D:/Ruby187/lib/ruby/1.8/webrick/server.rb:92:in `start'
D:/Ruby187/lib/ruby/1.8/webrick/server.rb:23:in `start'
D:/Ruby187/lib/ruby/1.8/webrick/server.rb:82:in `start'
-e:2:in `load'
-e:2

On Fri, Dec 16, 2011 at 2:03 PM, Michael Pavling wrote:
On 16 December 2011 07:54, sachin kewale wrote:
hi all,
i am getting following error ,i can't figure it out why and from where it
is coming ?
It would help if you had not cropped the top of the error which tells
you _exactly_ which line is causing the error :-/
ActionView::TemplateError (You have a nil object when you didn't expect it!
You might have expected an instance of ActiveRecord::Base.
The error occurred while evaluating nil.[]) on line #61 of
app/views/layouts/main_bk_layout.rhtml:
58: <%if @session != nil%>
59: <table width="250" border="0" height="20"
align="right" cellspacing="0" cellpadding="0">
60: <%else%>
61: <%if @session['user'].first_name == "admin"%>
At a guess, I'd say you don't have an element in your @session
variable for 'user'; hence the "nil object when you didn't expect it".

But that's just a guess based on the info given...

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

--
(¨ `·.·´ ¨) Always
`·.¸(¨ `·.·´ ¨) Keep
(¨ `·.· ´¨)¸.·´ Smiling!!
`·.¸.·´

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

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 3 of 5 | next ›
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedDec 16, '11 at 7:55a
activeDec 16, '11 at 9:28a
posts5
users3
websiterubyonrails.org
irc#RubyOnRails

People

Translate

site design / logo © 2021 Grokbase