{"id":41759050,"url":"https://github.com/ream88/mongoid-undo","last_synced_at":"2026-01-25T02:05:50.649Z","repository":{"id":6055116,"uuid":"7280297","full_name":"ream88/mongoid-undo","owner":"ream88","description":"Super simple undo for your Mongoid app","archived":false,"fork":false,"pushed_at":"2016-03-17T16:23:19.000Z","size":73,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-11T17:36:40.267Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ream88.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-12-21T23:00:27.000Z","updated_at":"2017-05-30T09:00:18.000Z","dependencies_parsed_at":"2022-08-20T23:40:35.354Z","dependency_job_id":null,"html_url":"https://github.com/ream88/mongoid-undo","commit_stats":null,"previous_names":["haihappen/mongoid-undo"],"tags_count":15,"template":false,"template_full_name":null,"purl":"pkg:github/ream88/mongoid-undo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ream88%2Fmongoid-undo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ream88%2Fmongoid-undo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ream88%2Fmongoid-undo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ream88%2Fmongoid-undo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ream88","download_url":"https://codeload.github.com/ream88/mongoid-undo/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ream88%2Fmongoid-undo/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28741649,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-25T01:40:51.112Z","status":"online","status_checked_at":"2026-01-25T02:00:06.841Z","response_time":113,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-01-25T02:05:50.529Z","updated_at":"2026-01-25T02:05:50.644Z","avatar_url":"https://github.com/ream88.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mongoid-undo [![Build Status](https://travis-ci.org/haihappen/mongoid-undo.svg?branch=master)](https://travis-ci.org/haihappen/mongoid-undo)\n\nSuper simple undo for your Mongoid app, based on both great modules\n[Mongoid::Paranoia](http://mongoid.org/en/mongoid/docs/extras.html#paranoia) and\n[Mongoid::Versioning](http://mongoid.org/en/mongoid/docs/extras.html#versioning).\n\n## How does it work?\n\n* `Mongoid::Paranoia` is used to mark documents as deleted, instead of deleting them really, otherwise restoring would be impossible ;).\n* `Mongoid::Versioning` is used to keep the older versions of your document, so we can restore them.\n* `Mongoid::Undo` adds an `action` field to your documents, so we can easily determine whether it was created, updated, or destroyed.\n\nBut instead of explaining all the details, you should get the idea by looking at the [Usage](https://github.com/haihappen/mongoid-undo#usage) section.\n\n\n## Installation\n\nIn your Gemfile:\n\n```ruby\ngem 'mongoid-undo'\n```\n\n\n## Usage\n\n```ruby\nclass Document\n  include Mongoid::Document\n  include Mongoid::Undo\nend\n```\n\n\n### Creating (and undoing)\n\n```ruby\ndocument = Document.create\ndocument.persisted? #=\u003e true\n\ndocument.undo\ndocument.persisted? #=\u003e false\n\ndocument.redo # A nice alias for undo ;)\ndocument.persisted? #=\u003e true\n```\n\n\n### Updating (and undoing)\n\n```ruby\ndocument = Document.create(name: 'foo')\n\ndocument.undoable? # =\u003e false\ndocument.save\ndocument.undoable? # =\u003e false\n\ndocument.update_attributes(name: 'bar')\ndocument.undoable? # =\u003e true\ndocument.name #=\u003e 'bar'\n\ndocument.undo\ndocument.name #=\u003e 'foo'\n\ndocument.redo\ndocument.name #=\u003e 'bar'\n```\n\n\n### Destroying (and undoing)\n\n```ruby\ndocument = Document.first\n\ndocument.destroy\ndocument.persisted? #=\u003e false\n\ndocument.undo\ndocument.persisted? #=\u003e true\n\ndocument.redo\ndocument.persisted? #=\u003e false\n```\n\n\n### Callbacks\n\nMongoid::Undo defines two callbacks which are called before and after `undo`, respectively `redo`. Both are based on `ActiveModel::Callbacks` which means they behave like the already known Rails callbacks.\n\n```ruby\nclass Document\n  include Mongoid::Document\n  include Mongoid::Undo\n\n  before_undo do\n    # Do something fancy.\n  end\n\n  before_redo { false } # Don't allow redoing.\nend\n```\n\n\n## Contributing\n\n1. Fork it\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Added some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create new Pull Request\n\n\n## Copyright\n\n(The MIT license)\n\nCopyright (c) 2012-2015 Mario Uher\n\nSee LICENSE.md.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fream88%2Fmongoid-undo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fream88%2Fmongoid-undo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fream88%2Fmongoid-undo/lists"}