diff options
author | Prathamesh Sonpatki <csonpatki@gmail.com> | 2016-10-05 22:04:33 +0530 |
---|---|---|
committer | Prathamesh Sonpatki <csonpatki@gmail.com> | 2016-12-09 00:00:50 +0530 |
commit | 44dc4f6645e12ddd5cf927bca0675a5b44d55cbd (patch) | |
tree | ed8d0a3bcb5292d13186e16fac1c5c7ab73a46d3 /activerecord/lib/active_record | |
parent | 9cbf54c81a46cc070f3997956c12915f39dbb46b (diff) | |
download | rails-44dc4f6645e12ddd5cf927bca0675a5b44d55cbd.tar.gz rails-44dc4f6645e12ddd5cf927bca0675a5b44d55cbd.tar.bz2 rails-44dc4f6645e12ddd5cf927bca0675a5b44d55cbd.zip |
Check whether the current attribute being write is aliased or not before writing
- If aliased, then use the aliased attribute name.
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/attribute_methods/write.rb | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/attribute_methods/write.rb b/activerecord/lib/active_record/attribute_methods/write.rb index f65c297e01..0022d526a4 100644 --- a/activerecord/lib/active_record/attribute_methods/write.rb +++ b/activerecord/lib/active_record/attribute_methods/write.rb @@ -29,7 +29,13 @@ module ActiveRecord # specified +value+. Empty strings for Integer and Float columns are # turned into +nil+. def write_attribute(attr_name, value) - write_attribute_with_type_cast(attr_name, value, true) + name = if self.class.attribute_alias?(attr_name) + self.class.attribute_alias(attr_name).to_s + else + attr_name.to_s + end + + write_attribute_with_type_cast(name, value, true) end def raw_write_attribute(attr_name, value) # :nodoc: |