Module: CompositePrimaryKeys::CompositeRelation
- Includes:
- ActiveRecord::Batches, ActiveRecord::Calculations, ActiveRecord::FinderMethods, ActiveRecord::QueryMethods
- Defined in:
- lib/composite_primary_keys/composite_relation.rb
Instance Method Summary collapse
Methods included from ActiveRecord::QueryMethods
Methods included from ActiveRecord::FinderMethods
#apply_join_dependency, #construct_relation_for_exists, #find_one, #find_some, #find_some_ordered, #find_with_ids, #limited_ids_for, #ordered_relation
Methods included from ActiveRecord::Calculations
#aggregate_column, #build_count_subquery, #calculate, #execute_simple_calculation
Methods included from ActiveRecord::Batches
Instance Method Details
#destroy(id_or_array) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/composite_primary_keys/composite_relation.rb', line 8 def destroy(id_or_array) # Without CPK: #if id.is_a?(Array) # id.map { |one_id| destroy(one_id) } #else # find(id).destroy #end id_or_array = if id_or_array.kind_of?(CompositePrimaryKeys::CompositeKeys) [id_or_array] else Array(id_or_array) end id_or_array.each do |id| where(cpk_id_predicate(table, self.primary_key, id)).each do |record| record.destroy end end end |