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.
A8e90e6f310e36963dfd432a66e2e558?d=identicon&s=25 Berlin Brown (Guest)
on 2006-05-29 18: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 Brown
(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
B780ee0ee1480454a85df58536702f63?d=identicon&s=25 Alder Green (Guest)
on 2006-05-29 19:14
(Received via mailing list)
On 5/29/06, Berlin Brown <bigbinc097@comcast.net> 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.