Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix reset_session with ActiveRecord store [#2200 state:resolved]

  • Loading branch information...
commit 01d7acd11d631d980497870aad1af42a0c66115c 1 parent b33c0d9
@josh josh authored
View
6 actionpack/test/activerecord/active_record_store_test.rb
@@ -28,9 +28,9 @@ def get_session_id
end
def call_reset_session
- session[:bar]
+ session[:foo]
reset_session
- session[:bar] = "baz"
+ session[:foo] = "baz"
head :ok
end
@@ -91,7 +91,7 @@ def test_setting_session_value_after_session_reset
get '/get_session_value'
assert_response :success
- assert_equal 'foo: nil', response.body
+ assert_equal 'foo: "baz"', response.body
get '/get_session_id'
assert_response :success
View
10 activerecord/lib/active_record/session_store.rb
@@ -295,7 +295,7 @@ def get_session(env, sid)
def set_session(env, sid, session_data)
Base.silence do
- record = env[SESSION_RECORD_KEY] ||= find_session(sid)
+ record = get_session_model(env, sid)
record.data = session_data
return false unless record.save
@@ -309,6 +309,14 @@ def set_session(env, sid, session_data)
return true
end
+
+ def get_session_model(env, sid)
+ if env[ENV_SESSION_OPTIONS_KEY][:id].nil?
+ env[SESSION_RECORD_KEY] = find_session(sid)
+ else
+ env[SESSION_RECORD_KEY] ||= find_session(sid)
+ end
+ end
def find_session(id)
@@session_class.find_by_session_id(id) ||
Please sign in to comment.
Something went wrong with that request. Please try again.