I want to set this routing:
http://localhost:3000/sites/search/www.google.com
My config/routes.rb
resources :sites, only: [:index] do
collection do
get 'search/:url', to: 'sites#search'
end
end
Routes:
GET /v1/sites/search/:url(.:format) v1/sites#search {:format=>:json}
Controller
def search
@url = params[:url]
end
But when I access from URI
http://localhost:3000/sites/search/www.google.com
Got
{
"status": 404,
"error": "Not Found",
"exception": "#<ActionController::RoutingError: No route matches [GET] \"/sites/search/www.google.com\">",
"traces": {
"Application Trace": [],