【发布时间】:2011-04-17 09:04:52
【问题描述】:
是否可以在 Rails 中将 Unicode 字符串设置为路径的一部分?
我尝试以下方法:
# 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 路线
杂志 GET /журналы(.:format) {:action=>"index", :controller=>"magazines"}
但是当我去路径时,我得到了路由错误:
$ w3m http://localhost:3000/журналы ... 路由错误 没有路线匹配“/%D0%B6%D1%83%D1%80%D0%BD%D0%B0%D0%BB%D1%8B”这是服务器日志:
$ rails 很薄 ... 2010 年 9 月 26 日 13:35:00 +0400 开始为 127.0.0.1 获取“/%D0%B6%D1%83%D1%80%D0%BD%D0%B0%D0%BB%D1%8B” ActionController::RoutingError(没有路由匹配“/%D0%B6%D1%83%D1%80%D0%BD%D0%B0%D0%BB%D1%8B”): 在救援/布局中渲染 /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.0.0/lib/action_dispatch/middleware/templates/rescues/routing_error.erb (1.2ms)谢谢。
Debian GNU/Linux 5.0.6;
红宝石 1.9.2;
Ruby on Rails 3.0.0。
【问题讨论】:
标签: ruby-on-rails ruby unicode routes