In this week’s post, we’ll be looking at the new Routing API in Rails 3. Other than handling all the basic routes efficiently, the new DSL also has some nice advanced features baked in that every developer will sure appreciate.
I have written about basic routing in Rails 3 over on the EngineYard blog before. This time, we’ll go through some of the more advanced examples of using routes. You’ll see how routes hook up with any Rack-compatible framework from a Rails application through routes. We’ll also see how constraints and redirect help you limit routes to a specific regular expression and manipulate them. At the end, we’ll go through some examples showing how flexible the new Routing DSL is.
For a more advanced example of using the Rails router, this week’s screencast walks you through creating a render method that you can use in the router itself to route a URL directly to a template. If you’re not familiar with the new router yet, definitely read the post before watching the screencast!