In my app a user can set the status of a Post to different flags like 'v' - visible, 'd' - mark for delete etc.
These flags are set via controller actions.
I have a batch process that runs and cleans all the posts marked for delete.
Post.find(:all, :conditions => ['status = ?', 'd']).each do |p| p.destroy end
This batch process runs every x many minutes.
Let's say a user marks the post with 'd' => batch process runs at some points => while the process is running the user marks the post as 'v'. Now inside the batch process the record is already targeted for delete and will be when the do loop is done, but the flag has changed via the controller action.
Ideally, if this happens I would like to not delete that post in the batch process.
What's the best way to handle this?