No commit activity in last 3 years
No release in over 3 years
Mongoid fork with support for Rails 4, for gem development. When releasing a gem, the gem can only depend on other released gems, not on github sources or paths. Mongoid has not yet released a gem supporting Rails 4. This gem is just a packaged version of the mongoid master branch, filling the gap until a release of mongoid with support for Rails 4.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

~> 2.11

Runtime

 Project Readme

Paranoid Documents for Mongoid 4 Build Status

There may be times when you don't want documents to actually get deleted from the database, but "flagged" as deleted. Mongoid-paranoia provides a Paranoia module to give you just that.

Old API from Mongoid 3.0 is extracted in 3.0.0-stable branch and doesn't work with Mongoid 4 anymore.

Installation

Add this line to your application's Gemfile:

gem 'mongoid-paranoia', github: 'simi/mongoid-paranoia' # before first release

Changes in 4.0

This will be changed soon - simi#5. Please leave a note if you don't like this behaviour, it will be merged soon.

Old syntax:

validates_uniqueness_of :title
validates :title, :uniqueness => true

New syntax:

validates :title, :uniqueness_including_deleted => true

Usage

class Person
  include Mongoid::Document
  include Mongoid::Paranoia
end

person.delete   # Sets the deleted_at field to the current time, ignoring callbacks.
person.delete!  # Permanently deletes the document, ignoring callbacks.
person.destroy  # Sets the deleted_at field to the current time, firing callbacks.
person.destroy! # Permanently deletes the document, firing callbacks.
person.restore  # Brings the "deleted" document back to life.

The documents that have been "flagged" as deleted (soft deleted) can be accessed at any time by calling the deleted class method on the class.

Person.deleted # Returns documents that have been "flagged" as deleted.

You can also access all documents (both deleted and non-deleted) at any time by using the unscoped class method:

Person.unscoped.all # Returns all documents, both deleted and non-deleted

TODO

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