Take the 2-minute tour ×

What are the cons in using the generic route:


I was told it is not recommended yet I do not see why. What problems can I get from using this?

share|improve this question
add comment

4 Answers

up vote 1 down vote accepted

Because it's easier to implement REST if you use the opposite ordering, ':controller(/:id(/:action))', and rails now has more convenient ways to get the proper HTTP verb using explicit resource routes.

Understanding the basic principles of REST will make it easier for you to expose an API, should you choose to go down that route, which embraces the principles of HTTP. It also tends to keep you from doing certain unclever things, like making it possible to delete records using a GET request. (The uncleverness might not be discovered until Google or your internal search bot decides to index all the links to :delete actions.)

The basic idea is that a GET /Url should imply fetching a resource. When you put the action first, the resource is semi-obscured, and you're accidentally opening the door to potential errors because all of the HTTP methods can be used to call destructive actions. Using an HTTP verb-centric approach, you can send an UPDATE request to the same URL as the SHOW request.

share|improve this answer
add comment

A specific answer to your question, which I understand to be understanding cons of the generic approach:

One significant risk is that you make every single controller action (non-protected) available to your users. It gives them the ability to access your entire 'tree' of controller actions, which may or may not be desirable depending on your situation.

In addition, you give users the ability to GET rather than POST, POST rather than GET, etc.

share|improve this answer
add comment

The comment above it that is generated explains it pretty nicely.


This means that you could theoretically do a GET request on a route that is only supposed to be accessible via POST. ie. You could do add a route called /postable to a user object, which should only be POST'd to, but if you use the rule above you can also do a GET request on it (with empty parameters).

share|improve this answer
add comment

You don't really get problems, per se. Instead, you lose out on the advantages you gain from using resource routing:

  • A common pattern that helps simplify controller design
  • Free RESTlike handling of HTTP verbs (GET, PUT, POST, DELETE)
  • Peace, Love and Happiness*

You can find out more about resource routing by reading the Rails Routing Guide.

* Peace, Love and Happiness not available in all areas. Terms and conditions apply.

share|improve this answer
add comment

Your Answer


