aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorNikita Afanasenko <nikita@afanasenko.name>2012-10-31 00:14:16 +0400
committerNikita Afanasenko <nafanasenko@spbtv.com>2012-10-31 13:16:44 +0400
commite7e59a75aad6c52b44cd97753b3dfce216833f1f (patch)
tree2881faff3383dc4207798cded01752ff397920f2 /activerecord/lib
parent85039d4b75ceb41a020e2cc8e3a0f39709b1fbc4 (diff)
downloadrails-e7e59a75aad6c52b44cd97753b3dfce216833f1f.tar.gz
rails-e7e59a75aad6c52b44cd97753b3dfce216833f1f.tar.bz2
rails-e7e59a75aad6c52b44cd97753b3dfce216833f1f.zip
Fix `attributes_before_type_cast` for serialised attributes.
Public method `attributes_before_type_cast` used to return internal AR structure (ActiveRecord::AttributeMethods::Serialization::Attribute), patch fixes this. Now behaves like `read_attribute_before_type_cast` and returns unserialised values.
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/attribute_methods/serialization.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/attribute_methods/serialization.rb b/activerecord/lib/active_record/attribute_methods/serialization.rb
index ada79c3567..5b9ed81424 100644
--- a/activerecord/lib/active_record/attribute_methods/serialization.rb
+++ b/activerecord/lib/active_record/attribute_methods/serialization.rb
@@ -119,6 +119,16 @@ module ActiveRecord
super
end
end
+
+ def attributes_before_type_cast
+ super.dup.tap do |attributes|
+ self.class.serialized_attributes.each_key do |key|
+ if attributes.key?(key)
+ attributes[key] = attributes[key].unserialized_value
+ end
+ end
+ end
+ end
end
end
end