views:

152

answers:

0

Hello Mongo Friends,

I'm starting off with a small Rails3:MongoDB:Mongoid project and came along some questions that's nature is more architectural.

When to use nested resources, and how deep to nest?

I'm not a friend of nested routes at all, but they become handy if not stacked deeper than 2 resources and document oriented databases like MongoDB seem to be a perfect target for nesting at all since documents itself are nested.

So my first question was: Should I use nested routes in case of a references_many <=> referenced_in association?

I tried, and since ActiveRecord's "build" is not existant, the whole controller stuff brake down to something that looked much nicer without nesting at all and doing all the stuff manually.

Am I wrong? Should I nest the routes of such associations too?

After that I came to my first embedded documents, and argued myself: Hey, this begs for nesting the routes. Some iterations later I ended up with 4 instead of 2 documents, every embedded in one of the others. So nesting the routes led to URL's I did'nt really like.

So the question to the already MongoDB-experienced user is: should I nest? And if yes, under what circumstanced and how deep?

Greets J.