diff options
author | Rafael França <rafaelmfranca@gmail.com> | 2018-11-29 15:31:24 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-29 15:31:24 -0500 |
commit | 5b75408e3226b43fab66558d173df7e97efbc240 (patch) | |
tree | 207983063d7581829ae42f59574f662737076aa7 /activerecord/lib | |
parent | c8e4d5a1e3be2290bc6007987e40312e19480474 (diff) | |
parent | 72e63c71bb3f73870e280964def25b7578818b1b (diff) | |
download | rails-5b75408e3226b43fab66558d173df7e97efbc240.tar.gz rails-5b75408e3226b43fab66558d173df7e97efbc240.tar.bz2 rails-5b75408e3226b43fab66558d173df7e97efbc240.zip |
Merge pull request #34569 from gmcgibbon/allow_attribute_aliases_in_update
Allow aliased attributes in update
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/attribute_methods/dirty.rb | 10 |
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 |