Skip to content

Instantly share code, notes, and snippets.

@reinh
Created October 29, 2009 18:11
Show Gist options
  • Save reinh/221655 to your computer and use it in GitHub Desktop.
Save reinh/221655 to your computer and use it in GitHub Desktop.
class ActiveRecord::Associations::HasManyThroughAssociation
private
def delete_records(records)
klass = @reflection.through_reflection.klass
method_map = {:destroy => :destroy_all}
method_name = method_map.fetch(@reflection.options[:dependent], :delete_all)
delete_method = klass.method(method_name)
records.each do |associate|
delete_method.call(construct_join_attributes(associate))
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment