i have a rails table setup called products and its all working well, lets assume i want to auto delete a record 3 weeks after creation how do go about the code
my produc
Create a rake task and run that rake task periodically. Something like:
delete_old_products.rake:
task delete_old_products: :environment do
Product.where("created_at <= ?", Time.now - 3.weeks).each do |product|
product.destroy
end
end
You can run that from the command line with rake delete_old_products