Skip to content

Commit

Permalink
Merge pull request #45662 from ghiculescu/patch-10
Browse files Browse the repository at this point in the history
Mention `Arel.sql` in `update_all` docs [docs]
  • Loading branch information
yahonda committed Jul 26, 2022
2 parents 71c0c81 + 82b8061 commit f34fbad
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion activerecord/lib/active_record/relation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,8 @@ def _exec_scope(...) # :nodoc:
#
# ==== Parameters
#
# * +updates+ - A string, array, or hash representing the SET part of an SQL statement.
# * +updates+ - A string, array, or hash representing the SET part of an SQL statement. Any strings provided will
# be type cast, unless you use `Arel.sql`. (Don't pass user-provided values to `Arel.sql`.)
#
# ==== Examples
#
Expand All @@ -463,6 +464,9 @@ def _exec_scope(...) # :nodoc:
#
# # Update all invoices and set the number column to its id value.
# Invoice.update_all('number = id')
#
# # Update all books with 'Rails' in their title
# Book.where('title LIKE ?', '%Rails%').update_all(title: Arel.sql("title + ' - volume 1'"))
def update_all(updates)
raise ArgumentError, "Empty list of attributes to change" if updates.blank?

Expand Down

0 comments on commit f34fbad

Please sign in to comment.