# Discard

> Soft deletes for ActiveRecord done right

Source: https://talira.ai/catalog/discard-3rzychgj
Every listing: https://talira.ai/catalog.md

- Kind: Open source
- Types: Library
- Categories: [libraries / databases / soft delete](https://talira.ai/categories/libraries/databases/soft-delete), [languages / ruby / rails](https://talira.ai/categories/languages/ruby/rails)
- Licence: MIT[^2]
- Pricing: Free and open source[^2]
- Free tier: yes[^2]
- Self-hostable: yes[^1]
- API: yes[^1]
- Creator: John Hawthorn

Discard adds soft deletes to Active Record models with a `discarded_at` timestamp: `discard` and `undiscard` set and clear it, `kept` and `discarded` scopes filter records, and callbacks can run before, after or around each. Unlike paranoia and acts_as_paranoid it overrides no Active Record methods (`destroy` and `delete` still delete) and adds no default scope, so discarded records are hidden only where you ask, and associated records are left alone unless your scopes or callbacks handle them. John Hawthorn, who helped maintain paranoia, wrote it in 2017; the README calls it feature-complete, and 2.0 (May 2026) requires Active Record 7.0 or later.

## Links

- GitHub: https://github.com/jhawthorn/discard

## Problems it solves

- hide deleted records in Rails without overriding destroy or adding a default scope
- archive a record so users can't see it but keep the row for history
- let an admin restore something that was removed by mistake
- soft-deleting a parent record shouldn't quietly delete all its child records
- keep a user's comments in their history after the post they were on was removed
- stop deactivated users from signing in while keeping their account row
- move off a paranoia-style gem but keep using the existing deleted_at column
- run code when a record is archived, like archiving its children too
- flag records as inactive with a timestamp and query only the active ones

## Features

- discard, discard!, undiscard and undiscard! on records
- discard_all and undiscard_all on scopes
- kept, undiscarded, discarded and with_discarded scopes
- discarded?, undiscarded? and kept? predicates
- before, after and around discard and undiscard callbacks
- discard and undiscard run in a transaction, so a callback error rolls back
- custom column name (keep deleted_at from paranoia)
- no overridden Active Record methods and no default scope

## Limitations

- Doesn't discard associated records recursively: there's no dependent: :destroy equivalent, so you use scopes or callbacks[^1]
- Doesn't restore associated records recursively[^1]
- Doesn't adjust counter cache columns: counts include discarded records[^1]

## Capabilities

- Has an API: plan not known

## Trust

Overall: 0.28 out of 1.
Signals: backing 0.20, extensibility 0.20.

- created by John Hawthorn

Warnings:

- GitHub activity not fetched yet

## Alternatives

- [Paranoia](https://talira.ai/catalog/paranoia-4nvnvejt.md): acts_as_paranoid for Rails 5, 6 and 7

## Sources

[^1]: https://github.com/jhawthorn/discard (checked 20 Nov 2026)
[^2]: https://github.com/jhawthorn/discard/blob/master/LICENSE.txt (checked 20 Nov 2026)
