diff options
author | Prathamesh Sonpatki <csonpatki@gmail.com> | 2015-01-11 13:53:28 +0530 |
---|---|---|
committer | Prathamesh Sonpatki <csonpatki@gmail.com> | 2015-01-18 20:00:57 +0530 |
commit | 0fcd4cf5c26c470623eef9af72a134ef6ba1a701 (patch) | |
tree | f1b09c2bcc6e467a0346de158c4218df65e80c46 /activerecord/lib | |
parent | 8a87ebfd8f5f3ca2e7d7c063f8cc98158896e475 (diff) | |
download | rails-0fcd4cf5c26c470623eef9af72a134ef6ba1a701.tar.gz rails-0fcd4cf5c26c470623eef9af72a134ef6ba1a701.tar.bz2 rails-0fcd4cf5c26c470623eef9af72a134ef6ba1a701.zip |
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.
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/persistence.rb | 2 |
1 files changed, 1 insertions, 1 deletions
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 |