Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

A Rails gem for enabling deactivation of ActiveRecord objects instead of deletion.

branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time




Deactivatable provides methods and a default_scope to allow ActiveRecord objects to be deactivated instead of deleted. This is useful if an object needs to be removed from general use, but its data needs to be retained. Additionally, Deactivatable provides the ability to specify dependencies which also need to be deactivated. Deactivation is determined by populating a deactivated_at field with the date time at which deactivation happened.


The deactivatable gem is hosted on GemCutter (

gem install deactivatable


config.gem 'deactivatable', :source => ''


  • Add a deactivated_at datetime field to any table you want to be deactivatable

    add_column :table_name, :deactivated_at, :datetime
  • Add the acts_as_deactivatable call to any class that should be deactivatable

      :dependencies - A list of symbols specifying any associations that are also deactivatable.  (The dependent association must separately be defined with acts_as_deactivatable).
      :auto_configure_dependencies - true or false (default).  If set to true, any association defined as :dependent => :destroy or :dependent => :delete_all will be added to the list of dependencies to deactivate.  NOTE: This call must occur after your dependency definitions to work properly.

Note on Patches/Pull Requests

  • Fork the project.

  • Make your feature addition or bug fix.

  • Add tests for it. This is important so I don't break it in a future version unintentionally.

  • Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but

    bump version in a commit by itself I can ignore when I pull)
  • Send me a pull request. Bonus points for topic branches.


Copyright © 2009 Greg Fitzgerald. See LICENSE for details.

Something went wrong with that request. Please try again.