I'm having trouble setting up nested resources is a certain way that I believe makes sense.
Given rules like these: * an owner owns many books * a book can be owned by many owners * an owner can own multiple copies of the same book
I have a many-to-many relationship of Owners-to-Books with the "link" table (we'll call it "Ownerships" since I can't think of a nice name) having an attribute for tracking the number of copies of a book an owner owns.
I have no problem listing all books, or listing all owners: * http://127.0.0.1:3000/books.xml * http://127.0.0.1:3000/owners.xml
What I can't figure out is how to set up my routes/controllers to list all books owned by a particular owner, and all owners that own a particular book (i.e. what I call "symmetrical routes for nested resources"). I'd like the URLs to look something like this: * http://127.0.0.1:3000/books/3/owners.xml (lists all owners of book 3) * http://127.0.0.1:3000/owners/7/books.xml (lists all books owned by owner 7)
What's extra tricky is that I want the listings to also contain the number of copies from the "link" table. So, for example, http://127.0.0.1:3000/owners/7/books.xml might return the equivalent of this as XML:
To Kill A MockingBird, 2 The Zombie Survival Guide, 1 War and Peace, 4
Please help this noob
Thanks,
Mike