digitalplaywright/mongoid-slug — pull request #165 by johnnyshields (2014-05-17 13:05:59+00:00)
Title: Fix compatibility between Mongoid::Paranoia and Mongoid::Slug

Currently, when Mongoid Paranoia deletes a document, it's `_slugs` field value remains in the DB. This can cause the unique index to throw an error when saving a new record with the same slug.

In order to fix this, we must unset the `_slugs` field when a paranoid doc is destroyed, and reset the slug when it is restored.

This PR includes the following changes:

- Add support for callbacks around the `restore` method, if not natively supported by the Mongoid::Paranoia implementation (simi/mongoid-paranoia supports it, mongoid-paranoia gem and Mongoid 3 do not.)

- Revert test mongoid-paranoia repo to 'simi/mongoid-paranoia'. Seems currently there are two competing mongoid-paranoia repos (see here: https://github.com/haihappen/mongoid-paranoia/issues/1)

- Rename `set_slug` method to `apply_slug`. The are new `set_slug` and `unset_slug` methods which literally call Mongoid `set` and `unset`.