Forum: Ruby on Rails Init lifecycle and rails

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Berlin B. (Guest)
on 2006-05-29 20:56
(Received via mailing list)
In a servlet J2EE application, there is an init style method that gets
called after that servlet is loaded.  Is there something similar within
a rails controller context.  I am looking for something where I can load
and setup a particular object.

Also, what about with sessions as well.  I would like to call some
library when a user session begins and possibly kill that object when
the session ends.

--
Berlin B.
(ramaza3 on freenode)
http://www.newspiritcompany.com
http://www.newspiritcompany.com/newforums
also checkout alpha version of botverse:
http://www.newspiritcompany.com:8086/universe_home
Alder G. (Guest)
on 2006-05-29 21:14
(Received via mailing list)
On 5/29/06, Berlin B. <removed_email_address@domain.invalid> wrote:
> In a servlet J2EE application, there is an init style method that gets
> called after that servlet is loaded.  Is there something similar within
> a rails controller context.  I am looking for something where I can load
> and setup a particular object.

Perhaps you want a before_filter?

http://api.rubyonrails.com/classes/ActionControlle...

> Also, what about with sessions as well.  I would like to call some
> library when a user session begins and possibly kill that object when
> the session ends.

Sessions are usually automatically created on Rails, by default, upon
first access. So it seems doubtful that there is a special callback,
since they are "nothing special". However, you can easily setup a
global method (through ApplicationController) that would
setup/teardown session, something like start_session/end_session.
This topic is locked and can not be replied to.