Skip to content


Subversion checkout URL

You can clone with
Download ZIP


i18n routes can't be recognized #3470

kuraga opened this Issue · 8 comments

6 participants


It seems the situation described here: is still aactual.

So, Rails correctly creates and stores utf-8 based routes. But when it comes to route recognition, it fails to match the route name:

get 'начало', controller: :home, action: :index

then http://localhost/%D0%BD%D0%B0%D1%87%D0%B0%D0%BB%D0%BE gives
No route matches "/%D0%BD%D0%B0%D1%87%D0%B0%D0%BB%D0%BE" with {:method=>:get}

The reason is that recognize_path does html unescape only after routes are mapped, and because of this it fails to map raw utf8 stored name against its %XX%XX equivalent.

Is this a bug? Can somebody help with this?


I think it should be CGI.unescape before roure recognize


Confirmed that this is still an issue on 3.2.2.


Still an issue in 3.2.5

Had a look into this today, and it seems that even if you had the paths unescaped this wouldn't work in rails at the moment.

Started by writing this failing test in actionpack/test/controller/routing_test.rb:

get 'начало', :controller => 'home', :action => 'index'
# and then later...
  {:controller => 'home', :action => 'index'}, 
  @routes.recognize_path('/начало', :method => :get)

First error you get is:

ActionController::RoutingError: bad URI(is not URI?): /начало

Which is actually a URI::InvalidURIError thrown by Rack::MockRequest.env_for calling URI('/начало').

Played around in IRB to sanity check:

$ irb -r 'uri'
> URI('начало')
URI::InvalidURIError: bad URI(is not URI?): /начало

As expected URI('ルービが好きです。') yielded the same error.


If we draw the following route,

get Rack::Utils.escape('こんにちは'), :controller => 'news', :action => 'index'

the following test is passed (on master).

def test_unicode_path
  assert_equal({:controller => 'news', :action => 'index'},
    @routes.recognize_path("/#{Rack::Utils.escape('こんにちは')}", :method => :get))

But I want to draw a route as

get 'こんにちは', :controller => 'news', :action => 'index'

WDYT ? :-)


How about kennyj@09fad24 ?
It's work fine, and all tests are green :-)


Anyway, I'll submit PR. Thanks !


Looks all good to me, let's see what core think.


Thank you! I can't write tests yet and haven't write this simple patch for seven month :) Will learn tests after exams ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.