Search code examples
ruby-on-railsactiondispatch

Optimizing Rails routing definition


We have about 650 routes defined in our Rails 3.2.22 app. Around 20 of them make up over 90% of our requests. These 20 all fall under an optional scope: (/:api_version). Where is the most optimal place to define these routes.

Is it at the beginning of the definition tree or the end? In other words, should they be defined by popularity in ascending or descending order?


Solution

  • You should also consider splitting your routes into namespaces and also separate files.

    There is a decent write up at http://blog.arkency.com/2015/02/how-to-split-routes-dot-rb-into-smaller-parts/