Kakurenbo

Kakurenbo provides soft delete. Kakurenbo is a re-implementation of paranoia and acts_as_paranoid for Rails4 and 3. implemented a function that other gems are not enough.

The usage of the Kakurenbo is very very very simple. Only add deleted_at(datetime) to column. Of course you can use acts_as_paranoid.In addition, Kakurenbo has many advantageous.

Installation

gem 'kakurenbo'

Usage

You need only to add 'deleted_at' to model.

rails generate migration AddDeletedAtToModels deleted_at:datetime

The model having deleted_at becomes able to soft-delete automatically.

Kakurenbo provides acts_as_paranoid method for compatibility.

Basic Example

soft-delete

model.destroy

# This is usable, too.
Model.destroy(id)
Model.destroy([id1,id2,id3])

when want without callbacks.

model.delete

restore a record

model.restore!

# This is usable, too.
Model.restore(id)
Model.restore([id1,id2,id3])

When restore, call restore callbacks.before_restore after_restore

hard-delete

model = Model.new
model.destroy!

check if a record is fotdeleted

model.destroyed?

find with soft-deleted

Model.with_deleted

find only the soft-deleted

Model.only_deleted

License

This gem is released under the MIT license.