Am i going crazy?!

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

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 B.

John B. 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 B.

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.

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 B.

John B. 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. :slight_smile:

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs