0.0
No commit activity in last 3 years
No release in over 3 years
A simple gem that adds mark_as_deleted ActiveRecord macro. Models having this are not actually being deleted, they are marked as deleted instead.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
>= 0

Runtime

 Project Readme

mark_as_deleted Build Status

mark_as_deleted is a small gem which simplifies adding 'marked as deleted' functionality to your models.

Installation

gem install mark_as_deleted

in your console, or

gem 'mark_as_deleted'

in your Gemfile.

Usage

Simply add a deleted boolean column to your model table and call mark_as_deleted in that model definition, and you are ready to go.

class Post < ActiveRecord::Base
  mark_as_deleted
end

Now the Post#destroy method won't erase the record from the database, it will update the deleted column to true instead.

If you want to give the column another name, you should just pass that name to the mark_as_deleted call, like so:

class Post < ActiveRecord::Base
  mark_as_deleted :is_deleted
end

Of course you must have a column by that name in your table.

Roadmap

  1. ActiveRecord scopes based on deleted column
  2. Maybe a generator creating a migration and adding mark_as_deleted to the model
  3. Maybe other ORMs support

Contributing

Fork the repository, push your changes to a topic branch and send me a pull request.