If you want to see the preview of the soft_destroy feature you need to just start this app and go to url:
https://localhost:3000/authors
The source code for the feature is located in:
lib/soft_destroy.rb
lib/soft_destroy/override_methods.rb
Feature's tests are located in:
test/soft_destroy/soft_destroy_test.rb
If you want to add your own model class with soft destroy feature. You need to add enable_soft_destroy in your model class:
class Book < ApplicationRecord
enable_soft_destroy
end
Then you need to add column in the table using migration
class AddSoftDeleteToBooks < ActiveRecord::Migration[5.0]
def change
add_column :books, :deleted, :boolean, :default => false
end
end
Then you can use it like that
Soft version:
Book.destroy
Book.destroy(:soft)
Book.soft_destroy
Hard version:
Book.destroy(:hard)
Book.hard_destroy