From b63701e272f3dc932ba7a20127f6dc82b567cfb4 Mon Sep 17 00:00:00 2001 From: Sean Griffin Date: Tue, 30 Oct 2018 12:52:23 -0600 Subject: `update_columns` raises if the column is unknown Previosly, `update_columns` would just take whatever keys you gave it and tried to run the update query. Most likely this would result in an error from the database. However, if the column actually did exist, but was in `ignored_columns`, this would result in the method returning successfully when it should have raised, and an attribute that should not exist written to `@attributes`. --- activerecord/lib/active_record/persistence.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'activerecord/lib') diff --git a/activerecord/lib/active_record/persistence.rb b/activerecord/lib/active_record/persistence.rb index 45ceb1e3ad..f991a3076e 100644 --- a/activerecord/lib/active_record/persistence.rb +++ b/activerecord/lib/active_record/persistence.rb @@ -479,15 +479,15 @@ module ActiveRecord verify_readonly_attribute(key.to_s) end + attributes.each do |k, v| + write_attribute_without_type_cast(k, v) + end + affected_rows = self.class._update_record( attributes, self.class.primary_key => id_in_database ) - attributes.each do |k, v| - write_attribute_without_type_cast(k, v) - end - affected_rows == 1 end -- cgit v1.2.3