Dread
// missing_dependents
Never dread about (not) destroying your records again!
Dread provides ways to:
- Draw a graph of dependently destroyable associations
- Find associations with missing depenent destroys/delets/nullifies
Supports Rails 3.2+ and Ruby 1.9.3+.
Installation
Add the Dread gem to your Gemfile:
group :development do
gem 'dread', '>= 0.0.7'
end
And run bundle install
within your app's directory.
Usage
The Dread gem provides a rake task for drawing all dependently destroyable associations.
$ rake dread class=user
user
tweets
comments
pictures
pictures
comments
pictures
avatar
Self joins
class Employee < ActiveRecord::Base
has_many :subordinates, class_name: Employee,
foreign_key: "manager_id",
dependent: :destroy
belongs_to :manager, class_name: Employee
end
$ rake dread class=employee
employee
subordinates
...
Circular dependent destroys
class Supplier < ActiveRecord::Base
has_one :account, dependent: :destroy
end
class Account < ActiveRecord::Base
belongs_to :supplier, dependent: :destroy
end
$ rake dread class=supplier
supplier
account
supplier
...
Development
Dread uses appraisals to test the code base against multiple versions of Rails.
When first developing, you should run bundle install
and appraisal install
to install the all dependencies accross different gemfiles.
Run appraisal rake
to roll the tests on multiple versions or just run a specific set with appraisal rails-4.0 rake
.
Bug reports
If you find a problem with the Dread gem, please submit an issue, along with the version of Rails you're using and the set of associations that are causing the trouble.
Contributing
- Fork it ( http://github.com/DamirSvrtan/dread/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -m 'Add new feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request