diff options
author | José Valim and Mikel Lindsaar <raasdnil@gmail.com> | 2010-01-22 13:37:29 +1100 |
---|---|---|
committer | José Valim and Mikel Lindsaar <raasdnil@gmail.com> | 2010-01-22 13:37:29 +1100 |
commit | 8a6a2ca712601a28087f78fb6080b05f526cb0fd (patch) | |
tree | de9347d6a398a4317e0c87981e8c75d442e141d7 /activerecord/lib/active_record/attribute_methods/write.rb | |
parent | c9dc1ac95bc97800dd3deb82fe1cf6f98e27413d (diff) | |
parent | 6d30002a52133bd105adb29084f4cc72b1ee847f (diff) | |
download | rails-8a6a2ca712601a28087f78fb6080b05f526cb0fd.tar.gz rails-8a6a2ca712601a28087f78fb6080b05f526cb0fd.tar.bz2 rails-8a6a2ca712601a28087f78fb6080b05f526cb0fd.zip |
Merge branch 'master' of git://github.com/rails/rails
Diffstat (limited to 'activerecord/lib/active_record/attribute_methods/write.rb')
-rw-r--r-- | activerecord/lib/active_record/attribute_methods/write.rb | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/attribute_methods/write.rb b/activerecord/lib/active_record/attribute_methods/write.rb index 37eadbe0a9..e31acac050 100644 --- a/activerecord/lib/active_record/attribute_methods/write.rb +++ b/activerecord/lib/active_record/attribute_methods/write.rb @@ -17,9 +17,14 @@ module ActiveRecord # Updates the attribute identified by <tt>attr_name</tt> with the specified +value+. Empty strings for fixnum and float # columns are turned into +nil+. def write_attribute(attr_name, value) - attr_name = _attributes.unalias(attr_name) + attr_name = attr_name.to_s + attr_name = self.class.primary_key if attr_name == 'id' @attributes_cache.delete(attr_name) - _attributes[attr_name] = value + if (column = column_for_attribute(attr_name)) && column.number? + @attributes[attr_name] = convert_number_column_value(value) + else + @attributes[attr_name] = value + end end private |