2010-09-26 15 views
7

क्या रेल में पथ के एक खंड के रूप में यूनिकोड स्ट्रिंग सेट करना संभव है?रेल पर रूबी। यूनिकोड मार्ग

मैं निम्न प्रयास करें:

 
    
# app/controllers/magazines_controller.rb 

class MagazinesController < ApplicationController 
    def index          
    end                   
end 
 
 
    
# encoding: utf-8 
# config/routes.rb 

PublishingHouse::Application.routes.draw do 
    resources :magazines, 
    :only => :index, 
    :path => :журналы # a Unicode string is set as a segment of the path 
end 
 
 
$ rake routes 
magazines GET /журналы(.:format) {:action=>"index", :controller=>"magazines"} 

लेकिन मैं रूटिंग त्रुटि मिलती है जब मैं पथ पर जाएँ:

:

 
$ w3m http://localhost:3000/журналы 
... 

Routing Error 

No route matches "/%D0%B6%D1%83%D1%80%D0%BD%D0%B0%D0%BB%D1%8B" 

यहाँ सर्वर लॉग है

 
$ rails s thin 
... 

Started GET "/%D0%B6%D1%83%D1%80%D0%BD%D0%B0%D0%BB%D1%8B" for 127.0.0.1 at 2010-09-26 13:35:00 +0400 

ActionController::RoutingError (No route matches "/%D0%B6%D1%83%D1%80%D0%BD%D0%B0%D0%BB%D1%8B"): 

Rendered /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.0.0/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (1.2ms) 

धन्यवाद।

डेबियन जीएनयू/लिनक्स 5.0.6;

रूबी 1.9.2;

रेल 3.0.0 पर रूबी।

उत्तर

11

इंट्रेटिंग, मुझे लगता है कि रेल को इसके लिए एक पैच चाहिए। मैं बाद में कोर से किसी के साथ बात करूँगा। इस बीच, निम्नलिखित कार्य करना चाहिए:

PublishingHouse::Application.routes.draw do 
    resources :magazines, 
    :only => :index, 
    :path => Rack::Utils.escape('журналы') # a Unicode string is set as a segment of the path 
end 
+0

यह काम करता है। बहुत धन्यवाद, ** रग्गी **। – Shamaoke

+0

इस पर रेलवे मुद्दे के रूप में चर्चा की गई है: https://github.com/rails/rails/issues/3470 –

संबंधित मुद्दे