Add the gem to your Gemfile and run bundle:
gem 'acts_as_paranoid', '~> 0.6.0'
2. Now you will need to add a migration to have a deleted_at column for the
models that you want to have the archiving functionality.
rails g migration add_deleted_at_to_posts deleted_at:datetime:index
after that you can run rails db:migrate to add the column to the table
3. Now all you have to do is add the method call acts_as_paranoid to the model
that you want the functionality added to, like this:
class Post < ApplicationRecord
acts_as_paranoid
end
acts_as_paranoid
end
4. https://www.dailysmarty.com/posts/how-to-soft-delete-in-rails( I use
this link to complete this task)
this link to complete this task)
No comments:
Post a Comment