我有一个带有搜索方法的CommunitiesSearchController。
我这样定义了它的路线:
namespace :api, defaults: { format: 'json' } do
namespace :v1 do
resources :communities
get 'community/search/coordinates/:latitude/:longitude', to: 'communities_search#search'
end
end
但是当我尝试访问它时:
ActionController::RoutingError (No route matches [GET] "/api/v1/community/search
/coordinates/49.2864807/-123.142214"):
我正在使用rails 5.
rails routes命令:
api_v1 GET /api/v1/community/search/coordinates/:latitude
/:longitude(.:format) api/v1/communities_search#search {:format=>"json"}
解决方案请查看: