Infinite Possibilities

Rails routing is implemented using a DSL—a Domain-Specific Language. Ruby lets developers build all kinds of functionality into a very concise form, but at the same time, DSLs can become pretty mind-bending quickly. Routing in particular can grow extremely complicated if you try to take advantage of too many cool Rails features. There are many, many more possibilities than a Learning book can reasonably cover. Among them are:

  • Using map.resources with a block

  • Custom parameters and conditions

  • Abandoning numeric id values in favor of more descriptive unique names

  • More precisely defined nested resources with path and name prefixes

  • Multiple levels of nesting

  • Testing routes with assert_generates, assert_recognizes, and assert_routing

  • Debugging routes from the console

  • Extending routing

Once you’ve run out of things to do with the possibilities explored in this chapter, and feel confident that you understand how Rails is routing requests, you can take the next steps forward into deepest Rails.

Get Learning Rails: Live Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.