为什么我的路线被忽略了呢?

时间:2017-03-21 03:31:33

标签: ruby-on-rails ruby-on-rails-5

我的代码在routes.rb中指定了以下路由:

concern :searchable do
  get "search(/:query)", controller: "search", action: :show, as: "search"
end

scope module: 'custom_domains', as: "custom_domain" do
   root to: "pages#show", id: "index"
   concerns :searchable

   get '/:id' => "pages#show", as: "page"

   match "*path" => "redirects#show", via: [ :get ], as: "redirect"
end

/                                                                        
/search(/:query)(.:format)       
/:id(.:format)                                                        
/*path(.:format)

当我尝试访问/search时,将跳过该路线并捕获与该路线匹配的所有*path。我很难过。路由从上到下定义并按此顺序匹配,因此我认为/search将是正确的匹配。你知道为什么不是这样吗?

0 个答案:

没有答案