I have a basic set up question for my nutrition application:
The application will have users who log in and receive MEAL prescriptions for the upcoming week. Tables can include:
User
Food
Recipe (perhaps Meal)
1. I can have a has_and_belongs_to_many relationship between "Food" and "Recipe". Many recipes comprised of many foods.
OR
2. I can use a self-joining association
Finally:class Meal < ActiveRecord::Base
has_many :foods, :class_name => "Meal",
:foreign_key => "recipe_id"
belongs_to :recipe, :class_name => "Meal"
end
I must remember the "User"... any need to consider polymorphic associations? The "User" will be prescribed "Meals" or "Recipes" on a weekly basis.
Thanks in advance.






Bookmarks