aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--activerecord/lib/active_record/store.rb1
-rw-r--r--activerecord/test/cases/store_test.rb5
2 files changed, 6 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/store.rb b/activerecord/lib/active_record/store.rb
index d5910df891..8cc84f81d0 100644
--- a/activerecord/lib/active_record/store.rb
+++ b/activerecord/lib/active_record/store.rb
@@ -37,6 +37,7 @@ module ActiveRecord
Array(keys).flatten.each do |key|
define_method("#{key}=") do |value|
send(store_attribute)[key] = value
+ send("#{store_attribute}_will_change!")
end
define_method(key) do
diff --git a/activerecord/test/cases/store_test.rb b/activerecord/test/cases/store_test.rb
index fb77220875..074fd39e65 100644
--- a/activerecord/test/cases/store_test.rb
+++ b/activerecord/test/cases/store_test.rb
@@ -26,4 +26,9 @@ class StoreTest < ActiveRecord::TestCase
assert 'graeters', @john.reload.settings[:icecream]
end
+
+ test "updating the store will mark it as changed" do
+ @john.color = 'red'
+ assert @john.settings_changed?
+ end
end