Forum: Ruby on Rails ActiveRecord question

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
98fa0eec8815e726d1b9f46f609004f8?d=identicon&s=25 Allen Walker (auswalk)
on 2009-02-20 20:54
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
A91bd6cef23eb3516245a092e196c4da?d=identicon&s=25 Maurício Linhares (mauricio)
on 2009-02-20 20:57
(Received via mailing list)
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/ (pt-br) | http://blog.codevader.com/
(en)



On Fri, Feb 20, 2009 at 4:54 PM, Allen Walker
98fa0eec8815e726d1b9f46f609004f8?d=identicon&s=25 Allen Walker (auswalk)
on 2009-02-20 21:09
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 Walker
This topic is locked and can not be replied to.