Session not working in testing mode


#1

Hi,

I’m having a problem with my sessions. I recently switched from storing
sessions on disk to storing them in MySQL. I ran rake
create_sessions_table to create the sessions table. But instead of just
using the standard table, I wanted something fancier. I would like to
know who is currently logged in, so I added the field user_id to the
sessions table. In the Rails wiki
(http://wiki.rubyonrails.com/rails/pages/HowtoChangeSessionStore) I read
that I could change the user_id in the sessions table by using
@session.model.user_id = @session[:user].id . model is a method
available when using active_record_store. This all works beautifully, at
least in development mode. However, the trouble starts when I run a
functional test. Everything blows up. The error I get is:

NoMethodError (undefined method `model’ for
#ActionController::TestSession:0x7019578)

So it appears to me that the method model is defined in development but
not in testing mode. But I cann’t find a solution for this problem. Any
help is appreciated.

Kind regards,

Nick