I prefer to filter the lists and then provide an “administrative”
function that runs the proper command for deleting expired items. It’s
part of my CYA philosophy… Always have the user process destructive
actions and only after a confirmation form. That way if they do
call you to ask about getting the data back you can say “sorry” in a
much nicer way.
You should be able to add :conditions to your find method:
:conditions => “date_expires >= now()”
And of course, your delete would just find with the reverse (<= now()).
I also like to toss in the confirmation page a “are you sure you’d like
to delete these (count) items” message just so they realize how
destructive the command will be.
I thought about what you said and agree. Instead of just purging them
I’d like to split my list method into 2 sides:
Current, which shows all the items belonging to the user that have not
expired
and a second section called ‘Expired’
which would show the expired items.
I thought about putting the conditions => “date_expires >= now()” in my
list view but that did not seem to work. How should one go about doing
it correctly?
Actually, I think I worked out a way to do it between the controller and
view (still not very familiar with the model but could not seem to get
it involved…)
If resources aren’t a problem, then generally speeking I’d keep all
the data. By all means have a method which only admins can access for
purging the data, but I wouldn’t use it unless my database size became
a problem. This way you as an admin can get at expired data for your
records, if the need should arise. You could even let the admin choose
when to purge from (ie, delete all records that expired more than
three weeks ago). Just my opinion.
-N