From 0fcd4cf5c26c470623eef9af72a134ef6ba1a701 Mon Sep 17 00:00:00 2001 From: Prathamesh Sonpatki Date: Sun, 11 Jan 2015 13:53:28 +0530 Subject: Run SQL only if attribute changed for update_attribute method - This is based on https://github.com/rails/rails/issues/18400 but tackling same issue with update_attribute method instead of update method. --- activerecord/lib/active_record/persistence.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activerecord/lib') diff --git a/activerecord/lib/active_record/persistence.rb b/activerecord/lib/active_record/persistence.rb index 6306a25745..714d36e7c0 100644 --- a/activerecord/lib/active_record/persistence.rb +++ b/activerecord/lib/active_record/persistence.rb @@ -246,7 +246,7 @@ module ActiveRecord name = name.to_s verify_readonly_attribute(name) send("#{name}=", value) - save(validate: false) + save(validate: false) if changed? end # Updates the attributes of the model from the passed-in hash and saves the -- cgit v1.2.3