Hi all,
just joined and have only just kicked off with Rails (coming, but not
departing, from WebObjects development). And so far there seems to be
a lot of promise except for one thing I can’t figure out as yet –
the above problem.
Say I have the following conceptual relationships:
ITEMS <<--->> CARTS
i.e., each item can belong to one or more categories. So really we have
ITEMS <<--> ITEMS_CARTS <-->> CARTS
where the join table, items_carts, has the dual primary keys
{items_id, carts_id}.
However, in reality people can and will buy more than one of each
item and so items_carts needs an additional attribute: quantity.
My question is how might the above be defined as a migration? In
WebObjects when modelling the above entities (akin to migrations) you
simply set the outer entities to propagate their primary keys.
I’ve searched google for quite some time but seem to keep finding
either objections to allowing for multiple primary keys (even though
many-to-many’s are common-place) or mention of work-a-rounds in
progress.
Any ideas?
I’ve seen the following article but it doesn’t go into enough detail
and straight away bypasses the abstract migration tool using instead
database specific sql (which suggests that the built in features may
not exist for this yet): http://jrhicks.net/Projects/rails/
has_many_and_belongs_to_many.pdf
On a similar note:
How does rails handle the plural expansion of words like ‘category’.
i.e., if you have a migration called categories is it going to
correctly use the singular for the model? That kind of naming scheme
doesn’t seem to make sense in enough situations, but anyway…
Thanks in advance…
with regards,
Lachlan Deck