Section 5. RESTful Routes
In many Rails projects,
routes.rb is one of the meanest, nastiest sections of code. Controllers get renamed in URLs and a million little named routes are created to assist in view creation. Resources can be used to partially clean up the
routes.rb mess. We can establish a controller as a resource using
map.resource. It also gives us method invocation via a URL and HTTP method as discussed in detail in Section 4. For our tasks controller from Section 4 we add the following simple route.
That’s it. Now we can access our tasks at
/tasks/1, along with the appropriate HTTP method.
With that out of the way, we examine the various options ...