Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #526 (closed defect: fixed)

Opened 4 years ago

Last modified 4 years ago

[PATCH] New update_many method allows update from an indexed hash

Reported by: duane.johnson@gmail.com Assigned to: David
Priority: normal Milestone:
Component: ActiveRecord Version: 0.9.4.1
Severity: normal Keywords:
Cc:

Description

Updates several records at a time using the pattern of a hash that contains id => {attributes} pairs as contained in +id_and_attributes_pairs+. If there are certain conditions that must be met in order for the update to occur, an optional block containing a conditional statement may be used. Example:

Person.update_many { 23 => { "first_name" => "John", "last_name" => "Peterson" },

25 => { "first_name" => "Duane", "last_name" => "Johnson" } }

# The following updates only those records whose first name begins with 'duane' or 'Duane'

Person.update_many @paramspeople? do |activerecord_object, new_attributes|

activerecord_object.first_name =~ /[dD]uane.*/

end

Attachments

update_many.patch (3.9 kB) - added by anonymous on 01/23/05 00:42:32.

Change History

01/23/05 00:42:32 changed by anonymous

  • attachment update_many.patch added.

01/24/05 14:15:28 changed by david

  • status changed from new to closed.
  • resolution set to fixed.