Rails 3路由:Globbing打破隐式(。:format)参数

时间:2011-02-12 08:51:07

标签: ruby-on-rails-3 routing glob

在Rails 3(.0.4)中,用户定义的路由在末尾有一个隐式(。:格式)参数(注意“as HTML / XML”):

match "/~(/:foo)" => "categories#index"

Started GET "/~/bar" for 127.0.0.1 at 2011-02-12 08:45:00 +0000
  Processing by CategoriesController#index as HTML
  Parameters: {"foo"=>"bar"}

Started GET "/~/bar.xml" for 127.0.0.1 at 2011-02-12 08:45:00 +0000
  Processing by CategoriesController#index as XML
  Parameters: {"foo"=>"bar"}

然而,通过globbing,这不再起作用了:

match "/~(/*foo)" => "categories#index"

Started GET "/~/bar" for 127.0.0.1 at 2011-02-12 08:48:14 +0000
  Processing by CategoriesController#index as HTML
  Parameters: {"foo"=>"bar"}

Started GET "/~/bar.xml" for 127.0.0.1 at 2011-02-12 08:48:19 +0000
  Processing by CategoriesController#index as HTML
  Parameters: {"foo"=>"bar.xml"}

为什么不,我怎样才能让它发挥作用?

0 个答案:

没有答案