Hi,
In my Rails app I have a has_many_through relation. I want to use the join model/table to store some data about the relation (how many times that particular relation is used, to be specific).
I'm writing an add-method on one of my classes which should check for any existing relation with the subject, update a counter on the relation if it exists or create it if it doesn't exist.
Example:
CoffeeDrinker is related to Coffee through Cup. Every time CoffeeDrinker takes a sip a counter on that particular Cup should be incremented. The first time CoffeeDrinker takes a sip, the Cup should be created and the counter initialized.
What is the easiest and/or most correct way to get a hold on the relation object?