Hi,
In my test case below, it seems that ‘initialize’ is called everytime
‘hello’ is called. Is this by design, a bug, or my pilot error?
class FooController < ApplicationController
def initialize
print "\n initialize \n"
end
def hello
print "\n hello \n"
end
end
I thought initialize will be called exactly once when the controller is
constructed and not when an action is executed.
Thanks for your help and sorry if duplicate,
-Danny
On 12/15/05, Danny H. [email protected] wrote:
def hello
print "\n hello \n"
end
end
I thought initialize will be called exactly once when the controller is
constructed and not when an action is executed.
On every request, a controller object is created. When the controller
object is created, the initialized function is called.
Well the controler gets created every time a action is called, HTTP is a
stateless protocol : )
If you’re in dev mode, I believe the controller would be reloaded
with every request so you would see initialize called for each
invocation of hello.
On Thu, 2005-12-15 at 15:47 -0800, Danny H. wrote:
def hello
print "\n hello \n"
end
end
I thought initialize will be called exactly once when the controller is
constructed and not when an action is executed.
This is correct, it’s just that a new FooController is being created
(instantiated, whatever) for each request.
On 12/15/05, Steven S. [email protected] wrote:
If you’re in dev mode, I believe the controller would be reloaded
with every request so you would see initialize called for each
invocation of hello.
Controllers get re-constructed on every invocation of every action, no
matter if you’re in development, test, or production mode.