How to do an applifecycle listener in rails?


#1

In jsp, we have applifecycle listeners. For each user that logs on, and
when
the app is started, and when session variable is changed, you can
specify a
function to run.

Is there something like this in Rails and any example code???


#2

You can use Observers for most of what a lifecycle listener would be
used for.
http://www.loudthinking.com/arc/000362.html
…and pages 271 and 279 of the “Agile Web D. with Ruby on
Rails” book.

Further, because all of the Rails classes are open, you can add
callbacks or observers to pretty much anything.
Beware, though, that Rails is a share-nothing design, which means that
there isn’t necessarily a single application container.
If you add code to “email the sys admin” when the app starts, he’ll
get one email for every FastCGI or SCGI process that starts.