I'm using the standard active_record_store in my app. In environment.rb
I have:
config.action_controller.session_store = :active_record_store
And my sessions
table was created with rake db:sessions:create
:
create_table :sessions do |t|
t.string :session_id, :null => false
t.text :data
t.timestamps
end
add_index :sessions, :session_id
add_index :sessions, :updated_at
However the updated_at
column isn't being updated on each request. It is being updated upon session creation (to the same value as created_at
, as expected) but not for any subsequent requests.
Oddly, if I declare the following explicit call in environment.rb
then the field is updated on each request:
class CGI::Session::ActiveRecordStore::Session
def before_save
self.updated_at = Time.now
end
end
Can anyone explain why this doesn't work by default?
I'm running Rails 2.1.0 -- and no, I can't upgrade Rails at the moment! :)