A
A
Anton Misyagin2016-07-23 12:51:30
Ruby on Rails
Anton Misyagin, 2016-07-23 12:51:30

How to prevent rails from mangling unicode links?

routes.rb :

get '/адрес/на/русском', :to => 'controller#action, :as => :russian

= link_to 'моя ссылка на русский урл', russian_path

At the output I get:
<a href="%2F%D0%B0%D0%B4%D1%80%D0%B5%D1%81%2F%D0%BD%D0%B0%2F%D1%80%D1%83%D1%81%D1%81%D0%BA%D0%BE%D0%BC">моя ссылка на русский урл</a>

but you need:
<a href="/адрес/на/русском">моя ссылка на русский урл</a>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman Mirilaczvili, 2016-07-23
@2ord

There is a better solution: gem https://github.com/romiras/rails-translate-routes
Gemfile:
allows you to store localized paths in the config/locales/routes.yml file

en:
  routes:
    # you can leave empty locales, for example the default one
es:
  routes:
    products: productos
    contact: contacto
    new: crear

and the paths themselves in the code remain clear

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question