Ruby on Rails - 找不到路由

时间:2017-01-13 14:22:01

标签: ruby-on-rails ruby

我有一个带有搜索方法的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"}

解决方案请查看:

Why do routes with a dot in a parameter fail to match?

0 个答案:

没有答案