Project

kakurenbo

0.02
No commit activity in last 3 years
No release in over 3 years
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.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.5
>= 0
>= 3.0.0
>= 0

Runtime

>= 4.0.2
 Project Readme

Kakurenbo

Kakurenbo provides soft delete. Kakurenbo is a re-implementation of paranoia and acts_as_paranoid for Rails4. 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.

Warning

kakurenbo is deprecated if you use in a new rails project!

You should use kakurenbo-puti!

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

# if action is cancelled by callbacks, return false.
model.destroy

# if action is cancelled by callbacks, raise ActiveRecord::RecordNotDestroyed.
model.destroy!

# selected model will be destroyed.
Model.where(:foo => 'bar').destroy_all

when want without callbacks.

model.delete

# selected model will be deleted.
Model.where(:foo => 'bar').delete_all

restore a record

# if action is cancelled by callbacks, return false.
model.restore

# if action is cancelled by callbacks, raise ActiveRecord::RecordNotRestored.
model.restore!

When restore, call restore callbacks.before_restore after_restore

hard-delete

Use hard option.

model.destroy(hard: true)

# without callbacks.
model.delete(hard: true)

# selected model will be destroyed.
Model.where(:foo => 'bar').destroy_all(nil, hard: true)

# selected model will be destroyed.
Model.where(:foo => 'bar').delete_all(nil, hard: true)

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.