Skip to content

jonleighton/dependent_records

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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)]}

About

Lists the associated records which will be destroyed by destroying a particular record

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages