0.0
No commit activity in last 3 years
No release in over 3 years
Recursively delete a collection and its all assoication with less sqls
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

< 5, >= 4.0.0
 Project Readme

awesome_delete

Recursive delete appropriately

Recursively delete a collection and its all assoication with less sqls. It thinks about the following

  • STI (delete the associations of subclass)
  • polymorphism
  • counter_cache, touch (avoid to unnecessary handle)

Install

gem install awesome_delete

Example

class Form < ActiveRecord::Base
  has_many :fields, dependent: :destroy
end

class Field < ActiveRecord::Base
  has_many :options, dependent: :destroy
end

class Option < ActiveRecord::Base
end

# it deletes forms, fields and options
Form.delete_collection [1,4,5]

Overwrite __delete_collection class method if not satisfy your need.