So imagine a situation where you have many meals. You can then categorize these meals as you see fit. So the two objects would be
class Category < ActiveRecord::Base
attr_accessible :name
has_many :meal
end
class Meal < ActiveRecord::Base
attr_accessible :name
has_and_belongs_to_many :category
end
So categories don't really belong to a meal, but meals can belong to many categories.
Is this incorrect? Should category have has_and_belongs_to_many
instead? Or should this relationship be a has_many, :through
one?