aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/persistence.rb
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2018-07-31 08:17:45 +0900
committerRyuta Kamizono <kamipo@gmail.com>2018-07-31 08:31:46 +0900
commitc83e30da27eafde79164ecb376e8a28ccc8d841f (patch)
tree0fe10e509f684d4cee8e85d183f90e69acff84ea /activerecord/lib/active_record/persistence.rb
parente8dd2bf85716f4aaf3ea4223e748e539589937f6 (diff)
downloadrails-c83e30da27eafde79164ecb376e8a28ccc8d841f.tar.gz
rails-c83e30da27eafde79164ecb376e8a28ccc8d841f.tar.bz2
rails-c83e30da27eafde79164ecb376e8a28ccc8d841f.zip
Avoid extra scoping when using `Relation#update`
Since 9ac7dd4, class level `update`, `destroy`, and `delete` were placed in the `Persistence` module as class methods. But `Relation#update` without passing ids which was introduced at #11898 is not a class method, and it was caused the extra scoping regression #33470. I moved the relation method back into the `Relation` to fix the regression. Fixes #33470.
Diffstat (limited to 'activerecord/lib/active_record/persistence.rb')
-rw-r--r--activerecord/lib/active_record/persistence.rb4
1 files changed, 1 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/persistence.rb b/activerecord/lib/active_record/persistence.rb
index 155d67fd8f..05963e5546 100644
--- a/activerecord/lib/active_record/persistence.rb
+++ b/activerecord/lib/active_record/persistence.rb
@@ -107,13 +107,11 @@ module ActiveRecord
# When running callbacks is not needed for each record update,
# it is preferred to use {update_all}[rdoc-ref:Relation#update_all]
# for updating all records in a single query.
- def update(id = :all, attributes)
+ def update(id, attributes)
if id.is_a?(Array)
id.map { |one_id| find(one_id) }.each_with_index { |object, idx|
object.update(attributes[idx])
}
- elsif id == :all
- all.each { |record| record.update(attributes) }
else
if ActiveRecord::Base === id
raise ArgumentError,