Access session hash in behaviours

Hey All,

I have been having a little play around with behaviours trying to get a
better feel for how things work. Specifically I am working on a login
behaviour using McCray’s MalierBehaviour as a loose guide to see how

I face problems when trying to access the session hash to see if a user
been logged in successfully or not (undefined variable or method error).

My guess is (and this could be way wrong) that I cannot access the
hash as I would in a controller and therefore I need to include part of
rails framework in the behaviour to allow me to do so. This line of code
the MalierBehaviour led me to think that

class MailerTagError < StandardError; end

although I must confess I am a little new to ruby and rails and don’t
get whats going on there.

If anyone could point me in the correct direction it would be much


I’m kind of in the same boat that you are and one thing I have learned
is that you have access to the request object and the session with it.
But you have to uncomment line 4 in SiteController (session :off).

Hope it helps,

Adrian M.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs