Forum: Ruby on Rails Session not working in testing mode

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.
Nick S. (Guest)
on 2006-03-25 20:38
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/HowtoChang...) 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
This topic is locked and can not be replied to.