Fork me on GitHub

Overuse route customizations

22 Jul 2010

Wen-Tien Chang

Bad Smell

map.resources :posts, :member => { :comments => :get,
                                   :create_comment => :post,
                                   :update_comment => :put,
                                   :delete_comment => :delete }

According to Roy Fielding’s doctoral thesis, we should use restful routes to represent the resource and its state. Use the default 7 actions(index, show, new, edit, create, update and destroy) without overusing route customizations. The solution to solve the overuse route customizations is to find another resources


map.resources :posts do |post|
  post.resources :comments

So we use a new resources comments to avoid customization route create_comment, update_comment and delete_comment for resources post. Remember to use the default 7 actions for routes as possible as you can.