Mongoid Best Practice: NestedResources

I start with a small Rails3: MongoDB: Mongoid project and come up with some questions about the nature of architecture.

When to use the invested resources and how deep is the nest?

I am not a friend of nested routes in general, but they become convenient if they do not fit deeper than 2 resources, and document-oriented databases such as MongoDB seem to be an ideal target for nesting in general, since the documents themselves are nested.

So my first question is: should I use nested routes in case of reference_many <=> referenced_in?

I tried, and since ActiveRecord "build" does not exist, all the controller material slows down to something that looked much nicer, not nested at all, and all this was done manually.

Am I really wrong? Should I also set up routes for such associations?

After that, I came to my first attached documents and argued: Hey, this requires nesting routes. A few iterations later I ended up with 4 instead of 2 documents, each of which was embedded in one of the others. Therefore, the nesting of the routes led to a URL that I really didn't like.

So, the question is already the MongoDB user experience: should I socket? And if so, then under what circumstances and how deep?

hello J.

+3
1

. , , Railscast Mongoid. , , * reference_ *. . , Railscast. , ASCIIcast:

http://asciicasts.com/episodes/238-mongoid

, Mongoid, ActiveRecord, .

http://weblog.jamisbuck.org/2007/2/5/nesting-resources

+1

Source: https://habr.com/ru/post/1759199/


All Articles