Search⌘ K

Use Nested Routes Strategically

Learn more about the strategic implementation of nested routes.

We'll cover the following...

The Rails Routing Guide says, “Resources should never be nested more than [one] level deep.” This is for a good reason, as it starts to blur the lines about what resource is being manipulated, and it creates highly complex route helpers like manufacturer_widget_order_url that take several parameters. There are three main reasons to consider a nested route:

  • Subresource ownership
  • Namespacing
  • Organizing content pages

Create subresources judiciously

A subresource is something properly owned by a parent resource. Using our widget ...