Decrease complexity of routes in Rails

Dmytro Vasin
1 min readOct 25, 2017

--

Sometimes, when you working with large codebase your `routes.rb` files grows really fast and become very dirty.

There are several things that makes your routes file bigger:

  • Customisation of devise.
  • Specific gems that mount additional routes (Active Admin, ActionCable)
  • Sidekiq + SidekiqWeb + Basic authentication
  • Namespaces with APP or API

All this points leads to one fact — your file grows and it is hard to maintain it.

But do you need all this staff in regular work, when you add some controller with another resource? My answer was No.

With that line of code we can split our `routes.rb` file for small compact pieces and forget about huge and long file.

after routes splitting

Solution is pretty simple and elegant and in same time it makes life easy. :)

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

No responses yet

Write a response