Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Carl Vondrick
July 25, 2006, 3:36 am
rate this thread
I am having trouble wrapping my mind around the ActiveRecord pattern and
I understand that for each table, there should be a class, and each row
is is effectively an instance.
But, my problem arises when I look at foreign keys and advanced
relationships. For basic foreign keys, I can just automatically
reference to the object. Example:
id, cost, invoice_id
When working with an instance with items, I can easily load a new object
But, what if I am already working with invoice, and I want to load
items? I can't think of any way to abstractly relate the two.
Also, what if I want to two things that are both a "has many"
relationship? For example, if I take users that can have multiple
qualities, I would need three tables: one for users, one for the
qualities, and one to link.
id, user_id, quality_id
How does ActiveRecord adapt to this? Any insight that you have or
suggestions are appreciated! I can't think of an elegant solution.