I’m totally baffled by the relation between objects and the session
and when an object is still available. It seems to me that there
should be a simple session.rb file (like the session.java file in
WebObjects).
Right now, I’m just trying to figure out how to keep an object
around, say a User object, without saving it to the db, so that I can
tell at any point whether the user is logged in. I guess the answer
is:
session[:user] = @user
where @user contains an @logged_in property. But I have no idea when
I have to call:
@user = session[:user]
When is @user lost such that I need to grab it from the session hash
again? When I change controllers? Methods? It seems that @user is
an instance variable of the controller class where it’s declared so
@user shouldn’t be lost between method calls within a single
controller but it is. @user seems to be acting like a local
variable, user.
It doesn’t seem like I can access the session hash from a model for
some reason. Why not?
Also, If I generate a session_controller.rb does that have any kind
of special status or is it just like any other controller I generate?
Is there any reason to run the script/generate controller command
other than to save me a minute creating files (controller, helper,
view, test, etc.)?
thanks,
russ