Could someone please tell me why this is not working? See these are events, and when the "start_date" of each event goes by into yesterday, i want it to automatically be "archived", or set the active field to "0" this is what i''ve written so far, there''s no errors when i load it but it doesn''t actually change anything in the database. if anyone has any insight to a fairly new pragrammer, i would so appreciative. here''s what i have. def archive_events Sevent.find_all.each do |u| u.update_attributes(params[:active]) unless u.start_date > Date.today active = 0 end end This will probably be so simple, but you know how these things are, up late all night, trying and trying... thanks guys(and girls) JOn -- Posted via http://www.ruby-forum.com/.
not quite clear what you''re trying to do here, but if you''re trying to set active = 0 in the database then doing so before the update would help. Apologies if misunderstood. ........................................................................ .......... John Browning On 17 Aug 2006, at 15:31, Jon Mr wrote:> Could someone please tell me why this is not working? See these are > events, and when the "start_date" of each event goes by into > yesterday, > i want it to automatically be "archived", or set the active field > to "0" > this is what i''ve written so far, there''s no errors when i load it but > it doesn''t actually change anything in the database. if anyone has any > insight to a fairly new pragrammer, i would so appreciative. here''s > what > i have. > > > def archive_events > Sevent.find_all.each do |u| > u.update_attributes(params[:active]) unless u.start_date > > Date.today > active = 0 > end > end > > This will probably be so simple, but you know how these things are, up > late all night, trying and trying... thanks guys(and girls) > > JOn > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060817/2d8956c1/attachment.html
John Browning wrote:> not quite clear what you''re trying to do here, but if you''re trying > to set active = 0 in the database then doing so before the update > would help. Apologies if misunderstood. > > ........................................................................ > .......... > John BrowningWell, it set this as a before_filter in the controller so that it happens often.. does that help? i don''t know how else to explain it. sorry. -- Posted via http://www.ruby-forum.com/.
Instead of running this from the controller, probably better to do so via the runner script (see script/runner) to run it once a day, about 2am. In terms of updating, the only suggestion I can make is to update the variable *before* updating the database rather than after -- as you seem to do in the previous example code. allbests, ........................................................................ .......... John Browning On 17 Aug 2006, at 15:56, Jon Mr wrote:> John Browning wrote: >> not quite clear what you''re trying to do here, but if you''re trying >> to set active = 0 in the database then doing so before the update >> would help. Apologies if misunderstood. >> >> ..................................................................... >> ... >> .......... >> John Browning > > > Well, it set this as a before_filter in the controller so that it > happens often.. does that help? i don''t know how else to explain it. > sorry. > > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060817/4fb00542/attachment.html
John Browning wrote:> Instead of running this from the controller, probably better to do so > via the runner script (see script/runner) to run it once a day, about > 2am. In terms of updating, the only suggestion I can make is to > update the variable *before* updating the database rather than after > -- as you seem to do in the previous example code.Thanks!!! that makes all kinds of sense now!. as far as the script/runner .. . . i''ve never even heard of it, but it sounds awesome. if you can''t tell that i''m kinda new at this stuff already. :-) -- Posted via http://www.ruby-forum.com/.