# Re: session error in rails 1.1

**URL:** <https://www.ruby-forum.com/t/re-session-error-in-rails-1-1/56961>\
**Category:** Rails\
**Created:** [April 6, 2006, 2:15am UTC](https://www.ruby-forum.com/t/re-session-error-in-rails-1-1/56961 "2006-04-06T02:15:24Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Christopher\_Burnley](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/ecc23a/32.png) [@Christopher\_Burnley](https://www.ruby-forum.com/u/Christopher_Burnley)\
**Post date:** [April 6, 2006, 2:15am UTC](https://www.ruby-forum.com/t/re-session-error-in-rails-1-1/56961/1 "2006-04-06T02:15:24Z")

</div>

I’m not sure if this is correct or will help, but I ran into a  
problem after the 1.1 on my production server (FreeBSD 6.0, Apache2,  
fast\_cgi) where I would get an “application error”. It took me a  
while to figure out that the objects I was storing in the session  
objects were coming back nil when accessed within a view. I did the  
usual job of deleting the RUBY.Session objects in the temp directory,  
bounced the web server and the problem was still there. I started to  
think maybe there was an issue of scope with respect to the session  
objects.

In my code I had previously stored things in the session by typing:  
session[:xyz]= “blah”  
and everything worked, then I upgraded to 1.1 and started getting the  
errors. I went in and refactored all the session[:xyz] references to  
@session[:xyz]= “blah”  
bounced the server and everything worked like a charm. The strange  
thing was that this only affected production. I could load the  
console or webrick and everything behaved as expected which is why I  
am not certain if the problem somehow magically got fixed between  
server bounces but it is worth trying if you are having the same  
problem.

Regards,  
Chris Burnley

---

<div class="post-metadata">

**Author:** ![Christopher\_Burnley](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/ecc23a/32.png) [@Christopher\_Burnley](https://www.ruby-forum.com/u/Christopher_Burnley)\
**Post date:** [April 6, 2006, 4:16am UTC](https://www.ruby-forum.com/t/re-session-error-in-rails-1-1/56961/2 "2006-04-06T04:16:21Z")

</div>

On Wed, 2006-04-05 at 17:15 -0700, Christopher Burnley wrote:

> In my code I had previously stored things in the session by typing:  
> session[:xyz]= “blah”  
> and everything worked, then I upgraded to 1.1 and started getting the  
> errors. I went in and refactored all the session[:xyz] references to  
> @session[:xyz]= “blah”  
> bounced the server and everything worked like a charm. The strange  
> thing was that this only affected production. I could load the  
> console or webrick and everything behaved as expected which is why I  
> am not certain if the problem somehow magically got fixed between  
> server bounces but it is worth trying if you are having the same  
> problem.

* * *

FWIW, I use session[:key] = “value” (probably too frequently) and the  
migration to rails 1.1 had no impact on me and I have refactored  
nothing.  
CentOS 4  
httpd-2.0.52-22 (apache)  
mod\_fastcgi 2.4.2

Caig

---

<div class="post-metadata">

**Author:** ![Christopher\_Burnley](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/ecc23a/32.png) [@Christopher\_Burnley](https://www.ruby-forum.com/u/Christopher_Burnley)\
**Post date:** [April 8, 2006, 4:15pm UTC](https://www.ruby-forum.com/t/re-session-error-in-rails-1-1/56961/3 "2006-04-08T16:15:06Z")

</div>

this is starting to feel very buggy. This time all I did was change one  
line of an rhtml file, reload the browser and I got the error.

Maybe because I load my model into the session like

@entry = User.find(3)  
@session[:user] = @entry

when a user first logs in Its causing some funky behavior in rails ? I  
dont  
think adding a few lines of html to an rhtml file would make this popup  
b/c  
thats what happened this time.

adam

---

<div class="post-metadata">

**Author:** ![Christopher\_Burnley](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/ecc23a/32.png) [@Christopher\_Burnley](https://www.ruby-forum.com/u/Christopher_Burnley)\
**Post date:** [April 8, 2006, 5:06pm UTC](https://www.ruby-forum.com/t/re-session-error-in-rails-1-1/56961/4 "2006-04-08T17:06:53Z")

</div>

Thanks Bill I will give that a shot.

I assume this means in the views too right ?

adam

---

<div class="post-metadata">

**Author:** ![Christopher\_Burnley](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/ecc23a/32.png) [@Christopher\_Burnley](https://www.ruby-forum.com/u/Christopher_Burnley)\
**Post date:** [April 8, 2006, 4:33pm UTC](https://www.ruby-forum.com/t/re-session-error-in-rails-1-1/56961/5 "2006-04-08T16:33:19Z")

</div>

Hi Adam,

I think that perhaps what Craig was suggesting was that you replace  
@session[] with session[]. As I understand it, use of the @ is being  
deprecated to make local vs. instance vs. (what the heck is the right  
word to use for the type for session and params?). I was told this WRT  
@params, and I’d bet it’s true for @session too.

hth,  
Bill  
----- Original Message -----  
From: Adam D.  
To: removed\_email\_address@domain.invalid  
Sent: 2006-04-08 9:13 AM  
Subject: Re: [Rails] Re: session error in rails 1.1

this is starting to feel very buggy. This time all I did was change  
one line of an rhtml file, reload the browser and I got the error.

Maybe because I load my model into the session like

@entry = User.find(3)  
@session[:user] = @entry

when a user first logs in Its causing some funky behavior in rails ?  
I dont think adding a few lines of html to an rhtml file would make this  
popup b/c thats what happened this time.

adam

On 4/5/06, Craig W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:  
On Wed, 2006-04-05 at 17:15 -0700, Christopher Burnley wrote:  
\> I’m not sure if this is correct or will help, but I ran into a  
\> problem after the 1.1 on my production server (FreeBSD 6.0,  
Apache2,  
\> fast\_cgi) where I would get an “application error”. It took me a  
\> while to figure out that the objects I was storing in the session  
\> objects were coming back nil when accessed within a view. I did  
the  
\> usual job of deleting the RUBY.Session objects in the temp  
directory,  
\> bounced the web server and the problem was still there. I started  
to  
\> think maybe there was an issue of scope with respect to the  
session  
\> objects.  
\>  
\> In my code I had previously stored things in the session by  
typing:  
\> session[:xyz]= “blah”  
\> and everything worked, then I upgraded to 1.1 and started getting  
the  
\> errors. I went in and refactored all the session[:xyz] references  
to  
\> @session[:xyz]= “blah”  
\> bounced the server and everything worked like a charm. The strange  
\> thing was that this only affected production. I could load the  
\> console or webrick and everything behaved as expected which is why  
I  
\> am not certain if the problem somehow magically got fixed between  
\> server bounces but it is worth trying if you are having the same  
\> problem.  
----  
FWIW, I use session[:key] = “value” (probably too frequently) and  
the  
migration to rails 1.1 had no impact on me and I have refactored  
nothing.  
CentOS 4  
httpd-2.0.52-22 (apache)  
mod\_fastcgi 2.4.2

```
Caig

_______________________________________________
Rails mailing list
removed_email_address@domain.invalid
http://lists.rubyonrails.org/mailman/listinfo/rails

```

* * *

* * *

Rails mailing list  
removed\_email\_address@domain.invalid  
[http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

---

<div class="post-metadata">

**Author:** ![Christopher\_Burnley](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/ecc23a/32.png) [@Christopher\_Burnley](https://www.ruby-forum.com/u/Christopher_Burnley)\
**Post date:** [April 8, 2006, 6:39pm UTC](https://www.ruby-forum.com/t/re-session-error-in-rails-1-1/56961/6 "2006-04-08T18:39:51Z")

</div>

indeed, that is what I meant…

see this link from [wiki.rubyonrails.org](http://wiki.rubyonrails.org)

[http://wiki.rubyonrails.org/rails/pages/HowtoWorkWithSessions](http://wiki.rubyonrails.org/rails/pages/HowtoWorkWithSessions)

Craig
