deactivatable
Description
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 it’s 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.
Install
The deactivatable gem is hosted on GemCutter (gemcutter.org)
gem install deactivatable
OR
config.gem 'deactivatable', :source => 'http://gemcutter.org'
Usage
-
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
Options :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
Copyright © 2009 Greg Fitzgerald. See LICENSE for details.