I have the following rails route
resources :apps do
post "name/:text/,
:on => :member, :action => :register, :as => :register,
:text => /[^\/]+/
end
The url that hits it in json format is the following:
curl -v -s -H "Content-type: application/json" -d '' -X POST http://0.0.0.0:3000/apps/1/name/hello.json
When my rails controller receives the request above, it can't see that the .json
at the end of the url is part of the url encoding/extension and not part of hello. It sees the params as the following:
Parameters: {"id"=>"1", "text"=>"hello.json"}
instead of having "text" => "hello"
.
I also have respond_to :json
in my AppsController.
Any idea why this happens? and how to make rails parse the .json
out?