diff options
author | Joshua Peek <josh@joshpeek.com> | 2009-03-03 13:07:03 -0600 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2009-03-03 13:07:03 -0600 |
commit | 9b1b88f09cf1498f04e1cd469d0d5ffccf2b93cc (patch) | |
tree | f96b67e783b8f0537ffe9fe826578d87aa8bdaee /activerecord | |
parent | 4d4d2c3896ed5a5d74da833c5c3132f406f4eab7 (diff) | |
download | rails-9b1b88f09cf1498f04e1cd469d0d5ffccf2b93cc.tar.gz rails-9b1b88f09cf1498f04e1cd469d0d5ffccf2b93cc.tar.bz2 rails-9b1b88f09cf1498f04e1cd469d0d5ffccf2b93cc.zip |
Fixed reset_session for ActiveRecord session store [#2108 state:resolved]
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/session_store.rb | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/session_store.rb b/activerecord/lib/active_record/session_store.rb index de199d30bf..3cc4640f42 100644 --- a/activerecord/lib/active_record/session_store.rb +++ b/activerecord/lib/active_record/session_store.rb @@ -287,8 +287,7 @@ module ActiveRecord def get_session(env, sid) Base.silence do sid ||= generate_sid - session = @@session_class.find_by_session_id(sid) - session ||= @@session_class.new(:session_id => sid, :data => {}) + session = find_session(sid) env[SESSION_RECORD_KEY] = session [sid, session.data] end @@ -296,7 +295,7 @@ module ActiveRecord def set_session(env, sid, session_data) Base.silence do - record = env[SESSION_RECORD_KEY] + record = env[SESSION_RECORD_KEY] ||= find_session(sid) record.data = session_data return false unless record.save @@ -310,5 +309,10 @@ module ActiveRecord return true end + + def find_session(id) + @@session_class.find_by_session_id(id) || + @@session_class.new(:session_id => id, :data => {}) + end end end |