user142019
user142019

Reputation:

Expire models in Rails

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.

Upvotes: 1

Views: 912

Answers (1)

jdl
jdl

Reputation: 17790

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.

Upvotes: 2

Related Questions