Class variable does not retain its value in rails

Could it be that in Rails every single time the garbage collector
up the class? I understand that controllers are instantiated on every
request, but I would expect my class variable @@call_count to retain
value over requests, no?

In development mode your classes are reloaded for every request (so
that you changes to your code are picked up without a server restart).
In production mode each mongrel acts independently, so don't rely on
this sort of stuff other than as a cache.


Well, in production mode it would work similar to C++ / Java. As long
as the app is running, the value will be static. Just remember that it
is per server instance as well and will be erased if the server is
restarted. If you want something to be truly persistent, store it in a
persistent store like a database.


Trent Black wrote: