All Ruby on Rails Node JS Android iOS React Native Frontend

TIL #2: How to Always Include Language Code in Your Rails App URLs

In today's TIL...

Ruby on Rails!

When you're developing the multi-language application at some point you may encounter the need to always include language code in your URLs. 

The same happened to me and I found one extremely simple trick that will allow you to:

1. Always have language code in your URLs.

2. Redirect user to correct URL when someone tried to reach your app without language code given.

All you need to do is change slightly your config/routes.rb. Here you go:

Simple, isn't it?


TIL, or Today I Learned, is where our developers share the best tech stuff they found every day. You can find smart solutions for some issues, useful advices and anything which will make your developer life easier.

Photo by Sara Riaño on Unsplash

Code stories CTA
READ ALSO FROM Ruby/Ruby on Rails
Read also
Need a successful project?
Estimate project or contact us