I have a question regarding a simple app I am developing in Rails 3.1, but I am not sure of how to define the associations and am looking for advice on the best way to achieve the following.
I have tapes, each tape contains a barcode.
I have boxes, each box has a name
What i need to track is the act of associating the two , each day up to 24 tapes will be placed into a Box, so i need a way of creating a new association for existing boxes and existing tapes on a form, and ideally track some extra information.
The tapes are on a 5 week cycle, so after 5 weeks a tape will ( possibly ) be associated with a new box.
I am not sure how to model the associations, any help or input would be appreciated
Do you need to track which box it used to belong to? If not, this is a simple belongs_to/has_many association.
If you need to track past boxes, then you’ll need a join-model:
and change the box/tape associations to use “:through”