aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoshua Peek <josh@joshpeek.com>2008-12-15 19:25:31 -0600
committerJoshua Peek <josh@joshpeek.com>2008-12-15 19:25:31 -0600
commit43ac42c46a462e1453b1b97da00e11bff7bba55d (patch)
tree57d6562a61fda26dcb4e79fca70f2e61206bba5a
parented708307137c811d14e5fd2cb4ea550add381a82 (diff)
downloadrails-43ac42c46a462e1453b1b97da00e11bff7bba55d.tar.gz
rails-43ac42c46a462e1453b1b97da00e11bff7bba55d.tar.bz2
rails-43ac42c46a462e1453b1b97da00e11bff7bba55d.zip
Clear empty nil values in session hash before saving
-rw-r--r--actionpack/lib/action_controller/session/abstract_store.rb4
-rw-r--r--actionpack/lib/action_controller/session/cookie_store.rb25
2 files changed, 6 insertions, 23 deletions
diff --git a/actionpack/lib/action_controller/session/abstract_store.rb b/actionpack/lib/action_controller/session/abstract_store.rb
index b23bf062c4..c6dd865fad 100644
--- a/actionpack/lib/action_controller/session/abstract_store.rb
+++ b/actionpack/lib/action_controller/session/abstract_store.rb
@@ -32,7 +32,9 @@ module ActionController
end
def to_hash
- {}.replace(self)
+ h = {}.replace(self)
+ h.delete_if { |k,v| v.nil? }
+ h
end
private
diff --git a/actionpack/lib/action_controller/session/cookie_store.rb b/actionpack/lib/action_controller/session/cookie_store.rb
index f13c9290c0..f4089bfa8b 100644
--- a/actionpack/lib/action_controller/session/cookie_store.rb
+++ b/actionpack/lib/action_controller/session/cookie_store.rb
@@ -74,30 +74,11 @@ module ActionController
freeze
end
- class SessionHash < Hash
- def initialize(middleware, env)
- @middleware = middleware
- @env = env
- @loaded = false
- end
-
- def [](key)
- load! unless @loaded
- super
- end
-
- def []=(key, value)
- load! unless @loaded
- super
- end
-
- def to_hash
- {}.replace(self)
- end
-
+ class SessionHash < AbstractStore::SessionHash
private
def load!
- replace(@middleware.send(:load_session, @env))
+ session = @by.send(:load_session, @env)
+ replace(session)
@loaded = true
end
end