diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-06-07 15:09:23 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-06-07 15:09:23 -0300 |
commit | 4cf63ce3731a43bd98f7b92b43dcf1be99c0b183 (patch) | |
tree | c9f1c7f5243629daa263c9f863d596d07f788b17 /activerecord/lib/active_record/attribute_methods | |
parent | dc73e39b4d40f0965b000f84568f77f126ec8290 (diff) | |
parent | 2dca1ba039eb0d1adad089134749a5093b481666 (diff) | |
download | rails-4cf63ce3731a43bd98f7b92b43dcf1be99c0b183.tar.gz rails-4cf63ce3731a43bd98f7b92b43dcf1be99c0b183.tar.bz2 rails-4cf63ce3731a43bd98f7b92b43dcf1be99c0b183.zip |
Merge pull request #15546 from sgrif/sg-lazy-decorators
Don't query the database schema when calling `serialize`
Diffstat (limited to 'activerecord/lib/active_record/attribute_methods')
-rw-r--r-- | activerecord/lib/active_record/attribute_methods/serialization.rb | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/attribute_methods/serialization.rb b/activerecord/lib/active_record/attribute_methods/serialization.rb index 148fc9eae5..60debb7d18 100644 --- a/activerecord/lib/active_record/attribute_methods/serialization.rb +++ b/activerecord/lib/active_record/attribute_methods/serialization.rb @@ -58,11 +58,9 @@ module ActiveRecord Coders::YAMLColumn.new(class_name_or_coder) end - type = columns_hash[attr_name.to_s].cast_type - if type.serialized? - type = type.subtype + decorate_attribute_type(attr_name, :serialize) do |type| + Type::Serialized.new(type, coder) end - property attr_name, Type::Serialized.new(type, coder) # merge new serialized attribute and create new hash to ensure that each class in inheritance hierarchy # has its own hash of own serialized attributes |