我的代码在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
将是正确的匹配。你知道为什么不是这样吗?