Re: :active_record_store + :table_name_with_underscore session issues

Frederick Cheung
Thu, 29 Jan 2009 00:35:44 -0000

On 29 Jan 2009, at 00:26, Tim wrote:

>>
>> When I look in the sessions table the hashed data in the `data` field
>> looks normal, but there are integers being stored in the session_id
>> field, not the 32 character hashes I would expect.  And every page
>> reload creates a new session, the integer stored in the session_id
>> field is incremented by one.  I''m thinking session data is
being
>> written, but then cannot be retrieved.
>>

Hmm. The problem you have is that by setting primary key
to :table_name_with_underscore rails wants to use session_id as the
primary key to the sessions table. it also wants to use session_id for
the session identifier and for whatever reason, the primary key
''wins''.
You could fiddle the SessionClass for it to store the session
identifier in a different column (or
CGI::Session::ActiveRecordStore::Session.set_primary_key ''id''
would
probably do the trick if you can get away with it.

Fred


>> I''ve tried a number of things I found searching, such as:
>>
>> CGI::Session::ActiveRecordStore::Session.set_primary_key
''session_id''
>>
>> none of which help.  Any idea what I need to do?
>>
>> I have other, older Rails apps using active_record_store sessions
>> that
>> work just fine, but this is my first one on Rails 2.2.2 and so far
>> it''s a no-go.
>>
>> --
>> Greg Donaldhttp://destiney.com/
> >