Subject: Re: [Rails] Re: Update model with array of IDs

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" => "David" }, {
"first_name" => "Jeremy"}]

--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@xxxxxxxxxxxxxxxxx
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@xxxxxxxxxxxxxxxxx
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.

(C)2011 mailinglist-archive.com