Skip to content
A soft-delete library
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
gemfiles
lib
spec
.gitignore
.rspec
.travis.yml Test on Ruby 2.5 Mar 19, 2018
CHANGELOG.md
Gemfile
LICENSE.txt
README.md
Rakefile
zombie_record.gemspec

README.md

Zombie Record

Allows restoring your Active Records from the dead!

Build Status

Installation

Add this line to your application's Gemfile:

gem 'zombie_record'

And then execute:

$ bundle

Or install it yourself as:

$ gem install zombie_record

Usage

Simply include the ZombieRecord::Restorable in your model class:

class Book < ActiveRecord::Base
  include ZombieRecord::Restorable
end

Zombie Record assumes the model's table has a deleted_at column with the timestamp type.

You can now delete and restore Book records:

book = Book.find(42)
book.destroy

Book.find(42) # raises ActiveRecord::RecordNotFound.

book = Book.deleted.find(42)
book.restore!

Book.find(42) # returns the Book record.

Compatibility

Zombie Record only works with Active Record >= 4. For Active Record 3 compatibility, check out the activerecord-3 branch of this gem.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request
You can’t perform that action at this time.