Re: session error in rails 1.1


#1

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


#2

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


#3

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


#4

Thanks Bill I will give that a shot.

I assume this means in the views too right ?

adam


#5

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


#6

indeed, that is what I meant…

see this link from wiki.rubyonrails.org

http://wiki.rubyonrails.org/rails/pages/HowtoWorkWithSessions

Craig