diff options
author | Jeremy Walker <jeremy@meducation.net> | 2012-08-09 12:44:59 +0100 |
---|---|---|
committer | Jeremy Walker <jeremy@meducation.net> | 2012-08-09 12:44:59 +0100 |
commit | 2a6039a81027a4f0f3f9fc4d95b6bba7323af28d (patch) | |
tree | daba0fa6fd00d60d1f36380880a05dc1e0ad9ef0 /activerecord/lib/active_record | |
parent | 2e98e0f38607d34a6cca8f9f7c5a4f318d681408 (diff) | |
download | rails-2a6039a81027a4f0f3f9fc4d95b6bba7323af28d.tar.gz rails-2a6039a81027a4f0f3f9fc4d95b6bba7323af28d.tar.bz2 rails-2a6039a81027a4f0f3f9fc4d95b6bba7323af28d.zip |
Ported PR #4856 to 3-2-stable.
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/store.rb | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/store.rb b/activerecord/lib/active_record/store.rb index 8cc84f81d0..49d01de365 100644 --- a/activerecord/lib/active_record/store.rb +++ b/activerecord/lib/active_record/store.rb @@ -36,11 +36,13 @@ module ActiveRecord def store_accessor(store_attribute, *keys) Array(keys).flatten.each do |key| define_method("#{key}=") do |value| + send("#{store_attribute}=", {}) unless send(store_attribute).is_a?(Hash) send(store_attribute)[key] = value send("#{store_attribute}_will_change!") end define_method(key) do + send("#{store_attribute}=", {}) unless send(store_attribute).is_a?(Hash) send(store_attribute)[key] end end |