diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2011-02-01 14:25:33 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-02-01 14:25:47 -0800 |
commit | a0fac7192241f3242af410ca16e6dd43b933c98e (patch) | |
tree | 2bc99ef839dfc2fda1328b8eabc4c5d4c2306f7a /activerecord/lib/active_record/base.rb | |
parent | ebe485fd8ec80a1a9b86516bc6f74bc5bbba3476 (diff) | |
download | rails-a0fac7192241f3242af410ca16e6dd43b933c98e.tar.gz rails-a0fac7192241f3242af410ca16e6dd43b933c98e.tar.bz2 rails-a0fac7192241f3242af410ca16e6dd43b933c98e.zip |
store the serialized column values in the @attributes hash
Diffstat (limited to 'activerecord/lib/active_record/base.rb')
-rw-r--r-- | activerecord/lib/active_record/base.rb | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 5310b55a92..6b82b827b0 100644 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -1739,18 +1739,25 @@ MSG # Returns a copy of the attributes hash where all the values have been safely quoted for use in # an Arel insert/update method. def arel_attributes_values(include_primary_key = true, include_readonly_attributes = true, attribute_names = @attributes.keys) - attrs = {} + attrs = {} + klass = self.class + arel_table = klass.arel_table + attribute_names.each do |name| if (column = column_for_attribute(name)) && (include_primary_key || !column.primary) if include_readonly_attributes || (!include_readonly_attributes && !self.class.readonly_attributes.include?(name)) - value = read_attribute(name) - coder = self.class.serialized_attributes[name] - if !value.nil? && coder - value = coder.dump value - end - attrs[self.class.arel_table[name]] = value + value = if klass.serialized_attributes[name] + @attributes[name] + else + # FIXME: we need @attributes to be used consistently. + # If the values stored in @attributes were already type + # casted, this code could be simplified + read_attribute(name) + end + + attrs[arel_table[name]] = value end end end |