I'm creating a simple paste-bin in Ruby on Rails, which will have an expire-feature. With this, people can select a date when the paste will be deleted automatically. How can I implement this? I was thinking of a cronjob
, but maybe there is a more platform-independent way, by defining this in the model itself. Can anyone help me? Thanks.
views:
56answers:
1
+1
A:
cron
will work fine. You can make a Rake
task that performs the actual deletions, and then trigger that from cron
.
Alternatively, you could keep the data forever and simply quit showing any records that have expiration dates in the past.
jdl
2010-04-24 15:00:49
I haven't thought of the second option. That one is actually greater than great! It will be more HTTP'ish, since I can use the right status-codes for permanently deleted resources, and some more things. Thanks!
Time Machine
2010-04-24 15:06:31
And it's also good for spam-recognation if I keep all spam-pastes in the DB. A paste-bin is namely a spammer's-heaven ;)
Time Machine
2010-04-24 15:08:28
you may also want to check out the whenever gem, see http://railscasts.com/episodes/164-cron-in-ruby
neutrino
2010-04-24 15:18:29