Update a lot of objects

can i update in one query a group of objects? i’ve something like: objs
= Model.find(:all, :conditions => …)…can i do something like
objs.update_attribute(:active, true) ?
i can’t do a objs.each do |obj| obj.update_attribute
because it’s in a script which run every 5 minutes…and N could be 1
as could be 10000 :frowning:

Model.update_all ‘active = true’, ‘your conditions’

http://api.rubyonrails.org/classes/ActiveRecord/Base.html#M000999

Cheers,
Yuri

On 6/3/07, mike [email protected] wrote:


Best regards,
Yuri L.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs