开发者

Unicode routes.rb and Passenger vs. Mongrel/WEBrick Options

My (Rails 3) routes.rb has the following entry:

resources :articles, :path => "記事" 

This works in my production environment, as passenger unescapes the path from /%E8%A8%98%E4%BA%8B to /記事.

However, in my 开发者_运维知识库development environment, I'm using Mongrel, which does not unescape the path, so it does not work unless I change my routes to

resources :articles, :path => Rack::Utils.escape("記事") 

I'm trying to figure out which component has the bug. Any suggestions?


This is a known passenger issue.

To work around it, you need to use the following:

match "記事" => "articles#index"
match "記事/:id" => "articles#show"
resources :articles, :path => Rack::Utils.escape("記事") 

This will ensure articles_path will generate the escaped routes, while still responding to the unescaped passenger ones.


I myself use passenger for development too. Since passenger 3 there is a Passenger Standalone. It works very well for me.

cd /path/to/your/railsproject
passenger start
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜