I was using a global ($) variable for this, but it seems global
variables remain loaded all the time that webrick is running, and I need
a fresh object for each HTTP request.
So I was trying to use the request.env array to add my own data there,
but it seems that that object isn’t created in environment.rb, so I
cannot use that approach. I need to create an object with some default
values on environment.rb, and then each controller can override any of
Could you please help me out?
As newby-on-rails, I don’t know if this suggestion will be of any help
to you, but for what it’s worth…
Because I will soon need to figure out how to do what is commonly
referred to as an “application variable” in other languages… (i.e. a
variable that all open sessions have access to).
I started doing some research & ran across something called “PStore”.
It’s described as a way of storing session information in a file in the
tmp dir… I know this is not what you are trying to do, but since it’s
possible, I assume, to read & write to this file from anywhere in the
app (I think read & write locking is built-in), perhaps you could use it
for your purposes?
I haven’t figured out how to use it yet, but here’s a wiki entry that
mentions it as well as other approaches;
I hope you get a more useful answer from someone who knows far more than