Module: Itemable::ActsAsItemable::HasManyItems::ClassMethods
- Defined in:
- lib/itemable/acts_as_itemable.rb
Instance Method Summary collapse
Instance Method Details
#has_many_items(association_name, options = {}) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/itemable/acts_as_itemable.rb', line 37 def has_many_items(association_name, ={}) = { through: :item_children, source: :child, source_type: association_name.to_s.classify }.merge(.symbolize_keys) if [:dependent] == :destroy before_destroy prepend: true do send(association_name).each do |rec| rec.destroy end end end has_many association_name, end |