Re: Re: Update model with array of IDs

Valery Kvon
Tue, 21 Feb 2012 20:00:23 -0000

On 21.02.2012, at 23:42, Rajarshi Chakravarty wrote:

> Thank you, Valery.
> You are my hero.
> Can you please post a link to the APIs?


api.rubyonrails.org

or

https://github.com/rails/rails/blob/d22592a05b299c21e30ec8b38890a178dca863b4/activerecord/lib/active_record/relation.rb#L312


people = { 1 => { "first_name" => "David" }, 2 => {
"first_name" => "Jeremy" } }
Person.update(people.keys, people.values)

people is a Hash
people.keys is an Array of keys # [1,2]
people.values is an Array of values # [{ "first_name" =>