From 72e63c71bb3f73870e280964def25b7578818b1b Mon Sep 17 00:00:00 2001 From: Gannon McGibbon Date: Thu, 29 Nov 2018 14:43:38 -0500 Subject: Allow aliased attributes in update Allow aliased attributes to be used in `#update_columns` and `#update`. --- activerecord/test/cases/attribute_methods_test.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'activerecord/test/cases') diff --git a/activerecord/test/cases/attribute_methods_test.rb b/activerecord/test/cases/attribute_methods_test.rb index 12a4027a4e..d341dd0083 100644 --- a/activerecord/test/cases/attribute_methods_test.rb +++ b/activerecord/test/cases/attribute_methods_test.rb @@ -323,6 +323,12 @@ class AttributeMethodsTest < ActiveRecord::TestCase assert_raises(ActiveModel::UnknownAttributeError) { topic.update(no_column_exists: "Hello!") } end + test "write_attribute allows writing to aliased attributes" do + topic = Topic.first + assert_nothing_raised { topic.update_columns(heading: "Hello!") } + assert_nothing_raised { topic.update(heading: "Hello!") } + end + test "read_attribute" do topic = Topic.new topic.title = "Don't change the topic" -- cgit v1.2.3