winton / acts_as_archive

Don't delete your records, move them to a different table
MIT License
372 stars 87 forks source link

Handling HABTM associations? #27

Closed cwade closed 13 years ago

cwade commented 13 years ago

First of all, thanks for this gem. I like the idea behind it and it's working great.

The only thing I haven't been able to figure out is how to handle many-to-many relationships. I have a Reservation class that has_and_belongs_to_many EquipmentPieces.

When a reservation is archived, I want to also archive the corresponding entries in the equipment_pieces_reservations table, but I haven't been able to figure out how to do this.

Thanks again.

cwade commented 13 years ago

Never mind - I figured it out. I can create a EquipmentPiecesReservation class that inherits from ActiveRecord::Base and then add that class to my acts_as_archive.yml file. Works like a charm - thanks!