Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/jisaacks/recurse-delete

Rails gem to recursively delete self and all dependent associations without an N+1
https://github.com/jisaacks/recurse-delete

Last synced: 22 days ago
JSON representation

Rails gem to recursively delete self and all dependent associations without an N+1

Awesome Lists containing this project

README

        

##Recurse Delete

When you call Record.destroy in Rails, it instantiates all its associations (that are :dependent => :destroy) and calls destroy on each. This is an N + 1, you can delete all the associated records without the N + 1 if you set the association as :dependent => :delete_all. However, this will not delete all the sub associations. This is the compromise recurse-delete solves. You can read more about it here: http://programming-perils.com/436/rails-prevent-dependent-destroy-n-plus-ones/

Add to GemFile: **gem 'recurse-delete'**

Usage: `Record.recurse_delete`