Skip to content
This repository

Welcome to the acts_as_paranoid wiki!

Installation

To install to your Rails project:

$ script/plugin install git://github.com/technoweenie/acts_as_paranoid.git

from your project root directory.

Set Up

Add a deleted_at column to the Model you want to make paranoid (NB replace “user” with the singular form of your Model):

$ script/generate migration add_deleted_at_to_user deleted_at:datetime

(don’t forget to run the migration)

Add acts_as_paranoid to your Model e.g.

class User < ActiveRecord::Base
  acts_as_paranoid
end

Now whenever destroy is called on that model, it is just removed from view and the deleted_at column set to the current date time. All the finder methods ignore “deleted” records.

If you want to see the hidden records, you can pass :with_deleted or :only_deleted to your find() call.

Something went wrong with that request. Please try again.