Take a look at Jose Valim's inherited_resources. It handles RESTful resources beautifully, and supports nesting.
However if your resources are uniquely addressable, you don't strictly need to nest them. The common advice recommends that you don't nest more than a single level deep. This is where :shallow
routes came from, giving the ability to express nested relationships in routes.rb without creating giant URLs and named routes. Shallow routes also help to improve flexibility, allowing resources to be moved around/in/out of hierarchies without otherwise updating code.
How would I construct the views and controllers to show only the Sections that belong to a particular Page...?
Well as this particular example is only a single level deep, it still falls within the recommendations for a single level of nesting: /pages/1/sections
. But for deeper nestings (or all if you kept everything top level), you would use the query string: e.g. /sections?page_id=1
or /sections/blocks?page_id=1
.
...and pass in a Page's id to the section#create method without nesting?
This one is more straightforward. Put it in the form itself (as a hidden input, likely).