# Update a lot of objects

**URL:** <https://www.ruby-forum.com/t/update-a-lot-of-objects/105857>\
**Category:** Rails\
**Created:** [June 3, 2007, 9:49pm UTC](https://www.ruby-forum.com/t/update-a-lot-of-objects/105857 "2007-06-03T21:49:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mike](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/58f4c7/32.png) [@mike](https://www.ruby-forum.com/u/mike)\
**Post date:** [June 3, 2007, 9:49pm UTC](https://www.ruby-forum.com/t/update-a-lot-of-objects/105857/1 "2007-06-03T21:49:06Z")

</div>

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 ☹

---

<div class="post-metadata">

**Author:** ![mike](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/58f4c7/32.png) [@mike](https://www.ruby-forum.com/u/mike)\
**Post date:** [June 3, 2007, 11:02pm UTC](https://www.ruby-forum.com/t/update-a-lot-of-objects/105857/2 "2007-06-03T23:02:08Z")

</div>

Model.update\_all ‘active = true’, ‘your conditions’

> **[ActiveRecord::Base](https://api.rubyonrails.org/classes/ActiveRecord/Base.html#M000999)**
>
> Active Record Active Record objects don't specify their attributes directly, but rather infer them from the table definition with which they're linked.

Cheers,  
Yuri

On 6/3/07, mike [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> >

–  
Best regards,  
Yuri L.
