aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/attribute_methods
diff options
context:
space:
mode:
authorGannon McGibbon <gannon.mcgibbon@gmail.com>2018-11-29 14:43:38 -0500
committerGannon McGibbon <gannon.mcgibbon@gmail.com>2018-11-29 14:49:17 -0500
commit72e63c71bb3f73870e280964def25b7578818b1b (patch)
treeeb8c7b4225d927ad244ae037db40e7b6ca1f0b46 /activerecord/lib/active_record/attribute_methods
parent5bb4546439ed20a864c6df18788dce0eb45d8326 (diff)
downloadrails-72e63c71bb3f73870e280964def25b7578818b1b.tar.gz
rails-72e63c71bb3f73870e280964def25b7578818b1b.tar.bz2
rails-72e63c71bb3f73870e280964def25b7578818b1b.zip
Allow aliased attributes in update
Allow aliased attributes to be used in `#update_columns` and `#update`.
Diffstat (limited to 'activerecord/lib/active_record/attribute_methods')
-rw-r--r--activerecord/lib/active_record/attribute_methods/dirty.rb10
1 files changed, 7 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/attribute_methods/dirty.rb b/activerecord/lib/active_record/attribute_methods/dirty.rb
index ebc2252c50..45e4b8adfa 100644
--- a/activerecord/lib/active_record/attribute_methods/dirty.rb
+++ b/activerecord/lib/active_record/attribute_methods/dirty.rb
@@ -158,9 +158,13 @@ module ActiveRecord
end
private
- def write_attribute_without_type_cast(attr_name, _)
- result = super
- clear_attribute_change(attr_name)
+ def write_attribute_without_type_cast(attr_name, value)
+ name = attr_name.to_s
+ if self.class.attribute_alias?(name)
+ name = self.class.attribute_alias(name)
+ end
+ result = super(name, value)
+ clear_attribute_change(name)
result
end