エラーが発生しました:
ActionController::RoutingError at /websites
No route matches {:controller=>"searches", :action=>"domain_results"}
次のリンクヘルパーを使用しようとした場合:
<%= link_to website.domain, domain_results_path(website.domain) %>
検索コントローラーでdomain_resultsを定義し、次のルートを設定しました。
get 'search/:domain/domain' => 'searches#domain_results', as: :domain_results, constraints: { domain: /.*/ }
レーキルート:
domain_results GET /search/:domain/domain(.:format) searches#domain_results {:domain=>/.*/}
私が以下を使用する場合、それは機能します:
<%= link_to website.domain, "/search/#{website.domain}/domain" %>
get 'search/:project/project' => 'searches#project_results', as: :project_results
<%= link_to website.domain, project_results_path(rental.project) %>
これは私が使用している制約によるものですか?「google.com.au」などの文字列をパスに渡すため、制約を使用する必要がありました。