public
Description: Lists the associated records which will be destroyed by destroying a particular record
Homepage:
Clone URL: git://github.com/jonleighton/dependent_records.git
name age message
file MIT-LICENSE Wed Sep 03 04:45:57 -0700 2008 Initial import [jonleighton]
file README.textile Wed Sep 03 04:48:56 -0700 2008 Try to fix formatting of README (again) [jonleighton]
file Rakefile Wed Sep 03 04:45:57 -0700 2008 Initial import [jonleighton]
file init.rb Wed Sep 03 04:45:57 -0700 2008 Initial import [jonleighton]
file install.rb Wed Sep 03 04:45:57 -0700 2008 Initial import [jonleighton]
directory lib/ Wed Sep 03 04:45:57 -0700 2008 Initial import [jonleighton]
directory spec/ Wed Sep 03 04:45:57 -0700 2008 Initial import [jonleighton]
directory tasks/ Wed Sep 03 04:45:57 -0700 2008 Initial import [jonleighton]
file uninstall.rb Wed Sep 03 04:45:57 -0700 2008 Initial import [jonleighton]
README.textile

Dependent Records

This Rails plugin reflects on a model’s associations, and returns a hash
of those which:

  1. Are not join associations
  2. Have the option :dependent => :destroy
  3. Are not empty
  4. Are one-to-many or many-to-many

I use it to show the user what the consequences of deleting a particular
record will be.

Example

Company.has_many :employees, :dependent => :destroy
@company.dependent_records
# => {"employees"=>[#(Employee id: 1), #(Employee id: 2)]}