aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/store.rb
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2012-02-02 12:07:28 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2012-02-02 12:07:28 -0800
commit2abaa19e77d1097730cfa6e0924ee7c1660ac01f (patch)
tree9fe5dfea9453878bb6fcfa621a904b4d92e0131d /activerecord/lib/active_record/store.rb
parent203962d89e863e1ab466bd65651d79a2f12a1fad (diff)
parent58d10e2012c414cc262b4b4f3305c3c4e0dbf048 (diff)
downloadrails-2abaa19e77d1097730cfa6e0924ee7c1660ac01f.tar.gz
rails-2abaa19e77d1097730cfa6e0924ee7c1660ac01f.tar.bz2
rails-2abaa19e77d1097730cfa6e0924ee7c1660ac01f.zip
Merge pull request #4856 from ihid/store_null_bug
Allow store to be a not null column.
Diffstat (limited to 'activerecord/lib/active_record/store.rb')
-rw-r--r--activerecord/lib/active_record/store.rb2
1 files changed, 2 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/store.rb b/activerecord/lib/active_record/store.rb
index d8338e2f5e..1c7b839e5e 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)
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