Ruby on rails RubyonRails。Unicode路由
是否可以将Unicode字符串设置为Rails中路径的一段 我尝试以下方法:Ruby on rails RubyonRails。Unicode路由,ruby-on-rails,ruby,unicode,routes,Ruby On Rails,Ruby,Unicode,Routes,是否可以将Unicode字符串设置为Rails中路径的一段 我尝试以下方法: # app/controllers/magazines_controller.rb class MagazinesController < ApplicationController def index end
# app/controllers/magazines_controller.rb
class MagazinesController < ApplicationController
def index
end
end
$rake路线
杂志获取/杂志获取(:格式){:操作=>“索引”,:控制器=>“杂志”}
但当我转到路径时,会出现路由错误:
$ w3m http://localhost:3000/журналы
...
Routing Error
No route matches "/%D0%B6%D1%83%D1%80%D0%BD%D0%B0%D0%BB%D1%8B"
W300万美元http://localhost:3000/журналы
...
路由错误
没有路由匹配“/%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)
她很瘦
...
在2010-09-26 13:35:00+0400开始获取127.0.0.1版本的“/%D0%B6%D1%83%D1%80%D0%BD%D0%B0%B0%BB%D1%8B”
ActionController::路由错误(没有路由匹配”/%D0%B6%D1%83%D1%80%D0%BD%D0%B0%D0%BB%D1%8B”):
rescues/layout中的Rendered/usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.0.0/lib/action\u dispatch/middleware/templates/rescues/routing\u error.erb(1.2ms)
谢谢
Debian GNU/Linux 5.0.6
Ruby 1.9.2
RubyonRails3.0.0.我认为Rails需要一个补丁。稍后我会和core的人谈谈这件事。同时,应采取以下措施:
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
这里将其作为Rails问题进行讨论: $ 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)
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