Forum: Ruby on Rails Where to initialize session variables?

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.
Ad8b580d8004335c95d2d15518168ce3?d=identicon&s=25 Jej (Guest)
on 2008-11-27 18: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?

Jej
6fabb84e727dee98d1277df56458cbac?d=identicon&s=25 Andrew Bloom (Guest)
on 2008-11-27 20: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?
  ....
end
This topic is locked and can not be replied to.