aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/attribute_methods
diff options
context:
space:
mode:
authorSean Griffin <sean@thoughtbot.com>2014-05-30 13:06:05 -0700
committerSean Griffin <sean@thoughtbot.com>2014-06-01 10:55:23 -0600
commit93734629a33591486b76e3b9884ea37650934eef (patch)
treedd4dd281a5db237c7e67ac01f1bfc0bbb725f98b /activerecord/lib/active_record/attribute_methods
parenta70b9ba62ed323347fe76be47afd80ee60729d9b (diff)
downloadrails-93734629a33591486b76e3b9884ea37650934eef.tar.gz
rails-93734629a33591486b76e3b9884ea37650934eef.tar.bz2
rails-93734629a33591486b76e3b9884ea37650934eef.zip
Don't change values in `@raw_attributes` during serialization
During `init_with`, the attributes given to the coder will be placed into `@raw_attributes`. As such, we should read from `@raw_attributes` when encoding, rather than `@attributes`, which has been type cast.
Diffstat (limited to 'activerecord/lib/active_record/attribute_methods')
-rw-r--r--activerecord/lib/active_record/attribute_methods/serialization.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/attribute_methods/serialization.rb b/activerecord/lib/active_record/attribute_methods/serialization.rb
index b247bf8a45..e8a52719ef 100644
--- a/activerecord/lib/active_record/attribute_methods/serialization.rb
+++ b/activerecord/lib/active_record/attribute_methods/serialization.rb
@@ -138,7 +138,7 @@ module ActiveRecord
attrs[name] = if self.class.serialized_attributes.include?(name)
@raw_attributes[name].serialized_value
else
- read_attribute(name)
+ read_attribute_before_type_cast(name)
end
end
end