How to initialize variables automatically on application bootstrap?

How to set some variables on bootstap? I need a few variables to be
initialized with default values every request. For example in ZF there
is a class Bootstrap whose methods are called automatically every
request. Is there something similar in Rails?

Do these need to be initialized before configuration? If not, you can
put them in config/initializers/

Never mind, I mis-read what you wrote.

ZF I'm assuming is Zend Framework, aka, PHP? Which works nothing like
Rails, btw, as you are essentially restarting the entire application
with every request in PHP.

The Rails application is not brought up and shut down for every
request. It lives in a long running process.

Maybe hardcoding them in a before_filter on ApplicationController…

Which kind of variables are you talking about? Where do you plan to use them?

Ricardo Franco wrote in post #1105627:

Maybe hardcoding them in a before_filter on ApplicationController...

Which kind of variables are you talking about? Where do you plan to use
them?

Yes, "before_filter" works just fine. Yet do not understand the details
how it works but it works :slight_smile:

I want to have a predefined variable in every method of my controllers.
It is @isAuth = false. I did like this in "application_controller.rb":

before_filter :setAuth
def setAuth
    @isAuth = false
end

Thanks.

tamouse mailing lists wrote in post #1105626:

Never mind, I mis-read what you wrote.

ZF I'm assuming is Zend Framework, aka, PHP? Which works nothing like
Rails, btw, as you are essentially restarting the entire application
with every request in PHP.

Yes, I meant Zend Framework.

The Rails application is not brought up and shut down for every
request. It lives in a long running process.

But how it can be? HTTP is a stateless protocol.

Right, but Rails implements a full application server within its long-running process, and maintains a session cookie to track individual users across multiple request loops. PHP is just beginning to be able to do this sort of thing, I think. Isn't there a server in the latest beta or alpha?

Walter

It is quite possible to build a statefull protocol on top of a stateless one.