# ActiveRecord question

**URL:** <https://www.ruby-forum.com/t/activerecord-question/160907>\
**Category:** Rails\
**Created:** [February 20, 2009, 8:54pm UTC](https://www.ruby-forum.com/t/activerecord-question/160907 "2009-02-20T20:54:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![hangingclowns](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/b5e925/32.png) [@hangingclowns](https://www.ruby-forum.com/u/hangingclowns)\
**Post date:** [February 20, 2009, 8:54pm UTC](https://www.ruby-forum.com/t/activerecord-question/160907/1 "2009-02-20T20:54:12Z")

</div>

This is strange: I’m doing the following in script/console:

> > Contract.find(:all) do |c|  
> > ?\> if c.use\_initial\_published\_date
> 
> > c.initial\_published\_date = Date.today  
> > c.save!  
> > end  
> > end

For some reason it is not saving the updated the records when I do this.  
Does anyone see a glaring error I’m making? c.use\_initial\_publised\_date  
is a boolean that is true for the last 3 records and false for the other  
100.

thanks

---

<div class="post-metadata">

**Author:** ![hangingclowns](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/b5e925/32.png) [@hangingclowns](https://www.ruby-forum.com/u/hangingclowns)\
**Post date:** [February 20, 2009, 8:57pm UTC](https://www.ruby-forum.com/t/activerecord-question/160907/2 "2009-02-20T20:57:59Z")

</div>

You’re missing the “each” call.

> > Contract.all.each do |c|  
> > ?\> if c.use\_initial\_published\_date  
> > c.initial\_published\_date = Date.today  
> > c.save!  
> > end  
> > end

- 

Maurício Linhares  
[http://alinhavado.wordpress.com/](http://alinhavado.wordpress.com/) (pt-br) | [http://blog.codevader.com/](http://blog.codevader.com/)  
(en)

On Fri, Feb 20, 2009 at 4:54 PM, Allen W.

---

<div class="post-metadata">

**Author:** ![hangingclowns](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/b5e925/32.png) [@hangingclowns](https://www.ruby-forum.com/u/hangingclowns)\
**Post date:** [February 20, 2009, 9:09pm UTC](https://www.ruby-forum.com/t/activerecord-question/160907/3 "2009-02-20T21:09:16Z")

</div>

LOL thanks. i drank too much last night i guess.

MaurÃ­cio Linhares wrote:

> You’re missing the “each” call.
> 
> On Fri, Feb 20, 2009 at 4:54 PM, Allen W.
