Topic: Access "session['user']" from before_save Active Record callback

Fellow Rails lovers,

I save my user in "session['user']" on login, and what I want to do is determine if I have a user logged in within the before_save Active Record callback (which I have as a method named "user?").

I thought it would be straightforward, but alas the "session[]" array is nil, yet I can use it in the controllers and views ok, happily displaying either the logged in username or anonymous in the interface with "session['user'].login".

Any ideas? Thanks in advance.

Re: Access "session['user']" from before_save Active Record callback

It is often best to have controllers direct traffic in terms of authentication. You can then do things like: if logged_in?

The model should contain logic pertaining to its domain, but where possible isolated from other problem spaces such as the authentication system.

Does this make sense?