Reputation: 35
I am new to RoR. I met one question which is: some active records may not needed to be searched for in database(let's say they are expired). I don't want to delete it from database because it is associated with other models. Also since it is expired, I don't want it to be updated. Is there any way to handle this situation in rails?
Upvotes: 0
Views: 74
Reputation: 36
Your question(s)
Upvotes: 0
Reputation: 1468
A Rails plugin to add soft delete.
This gem can be used to hide records instead of deleting them, making them recoverable later.
https://github.com/ActsAsParanoid/acts_as_paranoid
Upvotes: 1
Reputation: 2418
There are different ways. But I recommend you to use https://github.com/radar/paranoia
You can find a good screencast here: https://gorails.com/episodes/soft-delete-with-paranoia
It is really easy to add to your app. Just add the gem to your Gemfile and add acts_as_paranoid
to your model.
Upvotes: 0