aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorakihiro17 <coolwizard11@gmail.com>2015-10-05 02:49:57 +0900
committerakihiro17 <coolwizard11@gmail.com>2015-10-05 03:01:54 +0900
commitdc96af159ddb220fe87825d8538d7c4e86da995b (patch)
tree316a19db924690a007d790653a33241a5d89c91e /activerecord/lib
parentdf9faf53e9cfddd1be9a09811eed1192a3073afc (diff)
downloadrails-dc96af159ddb220fe87825d8538d7c4e86da995b.tar.gz
rails-dc96af159ddb220fe87825d8538d7c4e86da995b.tar.bz2
rails-dc96af159ddb220fe87825d8538d7c4e86da995b.zip
[ci skip] Fix ActiveRecord::Relation#update documentation
* before ``` people = Person.where(group: 'expert') people.update(group: 'masters') Note: Updating a large number of records will run a UPDATE query for each record, which may cause a performance issue. So if it is not needed to run callbacks for each update, it is preferred to use <tt>update_all</tt> for updating all records using a single query. ``` * after ``` people = Person.where(group: 'expert') people.update(group: 'masters') ``` Note: Updating a large number of records will run an UPDATE query for each record, which may cause a performance issue. So if it is not needed to run callbacks for each update, it is preferred to use <tt>update_all</tt> for updating all records using a single query.
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/relation.rb10
1 files changed, 5 insertions, 5 deletions
diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb
index e596df8742..36cdeed489 100644
--- a/activerecord/lib/active_record/relation.rb
+++ b/activerecord/lib/active_record/relation.rb
@@ -400,11 +400,11 @@ module ActiveRecord
# people = Person.where(group: 'expert')
# people.update(group: 'masters')
#
- # Note: Updating a large number of records will run a
- # UPDATE query for each record, which may cause a performance
- # issue. So if it is not needed to run callbacks for each update, it is
- # preferred to use <tt>update_all</tt> for updating all records using
- # a single query.
+ # Note: Updating a large number of records will run an
+ # UPDATE query for each record, which may cause a performance
+ # issue. So if it is not needed to run callbacks for each update, it is
+ # preferred to use <tt>update_all</tt> for updating all records using
+ # a single query.
def update(id = :all, attributes)
if id.is_a?(Array)
id.map.with_index { |one_id, idx| update(one_id, attributes[idx]) }