我有以下铁路路线
resources :apps do
post "name/:text/,
:on => :member, :action => :register, :as => :register,
:text => /[^\/]+/
end
以 json 格式点击它的 url 如下:
curl -v -s -H "Content-type: application/json" -d '' -X POST http://0.0.0.0:3000/apps/1/name/hello.json
当我的 rails 控制器收到上面的请求时,它看不到.json
url 末尾的 url 编码/扩展的一部分,而不是 hello 的一部分。它看到的参数如下:
Parameters: {"id"=>"1", "text"=>"hello.json"}
而不是拥有"text" => "hello"
.
我的 AppsController 中也有respond_to :json
。
知道为什么会这样吗?以及如何让rails解析.json
出来?