# How to save one value into the attributes of all rows in a model

**URL:** <https://www.ruby-forum.com/t/how-to-save-one-value-into-the-attributes-of-all-rows-in-a-model/165114>\
**Category:** Rails\
**Created:** [April 9, 2009, 9:56am UTC](https://www.ruby-forum.com/t/how-to-save-one-value-into-the-attributes-of-all-rows-in-a-model/165114 "2009-04-09T09:56:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tyanlion](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/f0a364/32.png) [@tyanlion](https://www.ruby-forum.com/u/tyanlion)\
**Post date:** [April 9, 2009, 9:56am UTC](https://www.ruby-forum.com/t/how-to-save-one-value-into-the-attributes-of-all-rows-in-a-model/165114/1 "2009-04-09T09:56:23Z")

</div>

When i use Model.all and i want to save this one value into all the  
rows of the model how do i do it without using a “for” loop.

---

<div class="post-metadata">

**Author:** ![tyanlion](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/f0a364/32.png) [@tyanlion](https://www.ruby-forum.com/u/tyanlion)\
**Post date:** [April 9, 2009, 10:11am UTC](https://www.ruby-forum.com/t/how-to-save-one-value-into-the-attributes-of-all-rows-in-a-model/165114/2 "2009-04-09T10:11:41Z")

</div>

On Thu, Apr 9, 2009 at 9:55 AM, tyliong [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> When i use Model.all and i want to save this one value into all the  
> rows of the model how do i do it without using a “for” loop.
> 
> >

Model.update\_all -

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

Andrew T.  
[http://ramblingsonrails.com](http://ramblingsonrails.com)  
[http://www.linkedin.com/in/andrewtimberlake](http://www.linkedin.com/in/andrewtimberlake)

“I have never let my schooling interfere with my education” - Mark Twain
