Ruby on rails 3 Rails 3:将路线设置为';获取';

Ruby on rails 3 Rails 3:将路线设置为';获取';,ruby-on-rails-3,Ruby On Rails 3,我的路线是: 匹配“api/v1/:id/:format/:date/(:type)”,:controller=>“xpto”,:action=>“api\u xpto” 目标是将其作为来自外部的GET请求。但是,未将路由设置为GET 如何使其成为GET?将匹配更改为GET: get 'api/v1/:id/:format/:date/(:type)', :controller => "xpto", :action => "api_xpto" 或添加:通过选项 match 'api

我的路线是:

匹配“api/v1/:id/:format/:date/(:type)”,:controller=>“xpto”,:action=>“api\u xpto”

目标是将其作为来自外部的GET请求。但是,未将路由设置为GET


如何使其成为GET?

匹配更改为GET

get 'api/v1/:id/:format/:date/(:type)', :controller => "xpto", :action => "api_xpto"
或添加:通过选项

match 'api/v1/:id/:format/:date/(:type)', :controller => "xpto", :action => "api_xpto", :via => :get

匹配更改为获取

get 'api/v1/:id/:format/:date/(:type)', :controller => "xpto", :action => "api_xpto"
或添加:通过选项

match 'api/v1/:id/:format/:date/(:type)', :controller => "xpto", :action => "api_xpto", :via => :get

实际上,
:as
用于命名路由。正确的选择是
:via=>:get
谢谢,写得太快了。已编辑。实际上,
:as
用于命名路线。正确的选择是
:via=>:get
谢谢,写得太快了。编辑。