Global variable problem in production environment

plz help me anyone we are writing some value to global varible in
application_helper file and accessing the same in views and layouts the
value of global varible changes dynamically whenever user logs in
(Example if user1 and user2 logs in at same time sometimes user2 is
veiwing user1 deatils in that global varible we are running the
application in production mode with apache 2.x version and passeneger
2.x version ) .plz suggest us how to use global varible in this scenario

2009/12/21 Nandan K. [email protected]:

plz help me anyone we are writing some value to global varible in
application_helper file and accessing the same in views and layouts the
value of global varible changes dynamically whenever user logs in
(Example if user1 and user2 logs in at same time sometimes user2 is
veiwing user1 deatils in that global varible we are running the
application in production mode with apache 2.x version and passeneger
2.x version ) .plz suggest us how to use global varible in this scenario

The solution is to not use global variables. It may be that session
variables are appropriate for your requirement if you wish data for a
user to persist across server requests. If you do not require
persistence then just use instance variables.

Colin

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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.

On Dec 21, 6:12 am, Nandan K. [email protected] wrote:

plz help me anyone we are writing some value to global varible in
application_helper file and accessing the same in views and layouts the
value of global varible changes dynamically whenever user logs in
(Example if user1 and user2 logs in at same time sometimes user2 is
veiwing user1 deatils in that global varible we are running the
application in production mode with apache 2.x version and passeneger
2.x version ) .plz suggest us how to use global varible in this scenario.

I would say “GB2PHP” based on this, but it wouldn’t work there
either… :slight_smile:

Seriously - 99% of the time, if you’re using a global variable, you’re
doing it wrong. Take a look at session variables in the
ActionController::Base docs:

I’d also strongly recommend that you get a good (recent) Rails
reference like Agile Web D. with Rails (3rd ed).

–Matt J.

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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.