Forum: Ruby on Rails Where to initialize session variables?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Jej (Guest)
on 2008-11-27 19:54
(Received via mailing list)
Hi all,

I would like to initialize some session variables when the user visits
the app for the first time. Currently I do it in an application
before_filter (escaped if the session already exists), but that occurs
for each request, it's dirty.

Do you have any better solution?

Andrew B. (Guest)
on 2008-11-27 21:05
(Received via mailing list)
The solution you have seems like a fine answer to me. Simple,
standard, and should be pretty easy for any incoming developer to
understand. If youve got a method like the following then it probably
isn't a big performance drain either.

before_filter :intialize_session_stuff
def intialize_session_stuff
  return if session_stuff_is_already_set?
This topic is locked and can not be replied to.