I have 3 models, let's call them Recipe, Fruit and Nut, and I need a
DRY way to set up their relationships.
Fruits and Nuts have different sets of properties
Fruits and Nuts go into a Recipe
A join model would be useful to track how much Fruit or Nut goes into a
Different Recipes may use a Nut with the name, but different property
I might want to add a Twig or Llama model to my Recipes
Right now I have a separate join models that do pretty much the same
for each of Fruit and Nut, but it's getting really wet (opposite of
DRY). It works just fine, but the code is getting really redundant.
Untill I can hack rails so has_many :through works with polymorphic
associations, what is a good way to do this?
class Recipe < AR::B
has_many :fruits, :through => :fruitaddition
has_many :nuts, :through => :nutaddition
class Fruit < AR::B
has_many :recipes, :through => :fruitadditions
class Nut < AR::B
has_many :recipes, :through => :nutadditions