From 58d10e2012c414cc262b4b4f3305c3c4e0dbf048 Mon Sep 17 00:00:00 2001 From: Jeremy Walker Date: Thu, 2 Feb 2012 18:57:15 +0000 Subject: Allow store to be a not null column. --- activerecord/lib/active_record/store.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'activerecord/lib/active_record') 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 -- cgit v1.2.3