The SitePoint Forums have moved.

You can now find them here.
This forum is now closed to new posts, but you can browse existing content.
You can find out more information about the move and how to open a new account (if necessary) here.
If you get stuck you can get support by emailing forums@sitepoint.com

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

how to handle "stacking order" of a collection

I suppose this may be more of a database question, but what is the best way to handle this scenario.
I have the following tables: articles, collections, articles_collections
a collection contains many articles but I want to be able to order them. Would I simply add a "stacking_order" column to the articles table?
Although, an article can belong to many collections and each would have different stacking orders.
Any suggestions?

It sounds like you want a join model between your Article and Collection. Without knowing more about your domain its hard to put a name to it, but lets say that model is called Foo. You'd have articles, collections and foos tables. The foos table will have an article_id, a collection_id and a stacking_order column. Your models would look a bit like this:

Hi,
I changed my has_and_belongs_to_many to use has_many through and now my tests are throwing mysql errors like "Cannot add or update a child row: a foreign key constraint fails:"
Any idea on what I'll need to do to fix?

When setting foreign keys what should set the "on delete" and "on update" handlers to CASCADE, SET_NULL, NO ACTION, RESTRICT

Personally, I wouldn't bother with foreign key constraints in your database unless it has to be accessed by several different apps. Use your Rails models to set your constraints. Database constraints just make things a pain in the **** to test.

No ideas, this is driving me insane.
I mean should what I'm doing here work?
Would a collection have a reference to an articles array? or since I am going thru collection_items would I have to access something like my_collection.collection_items.articles?

I have to say I thought habtm was confusing, but this tops it. I don't know if i'm being particularly dense, but i appreciate your help so far.

If you donít include the join association you will get an HasManyThroughAssociationNotFoundError error stating: Could not find the association :catalogue_items in model Vendor
I might be an idiot, and it might say this somewhere in the docs, but I struggled with this for a while, and couldnít find anything on the subject.

If you look about, on your associations you can use :dependant => :destroy to do that for you, there is a :delete_all option, that saves some processing overhead if there is no need for any callbacks for model destruction. ....