I'm creating an listings type of web application and would like users posts to automatically be deleted a certain time after there post/listing expires?
In more detail on the app you post, lets say a car-lift you will give someone to a destination. I want the post to delete itself 24 hours after the lift was done
Is cronjob/scheduler for rails the only way to do this? Isn't there an easier way?
I'm struggling to get my head around it.
Here is the code in: lib/tasks/scheduler.rake
desc "This task is called by the Heroku scheduler add-on"
task :delete_hosting => :environment do
=> not sure what goes here, something like => User.host.after_time.delete? //
end
Thanks
Resque-Scheduler is a perfect match for that functionality: https://github.com/bvandenbos/resque-scheduler
Resque.enqueue_in(1.day, DeleteUserPost, :user_post_id => user_post.id)
And in DeleteUserPost you code the deletion of the UserPost
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.