I have used friendly_id and globalize gem. So I can generate routes as;
/search/france/weekly/toyota-95
Here is my routes;
namespace :search do
resources :car_countries, path: '', only: [] do
resources :rental_types, path: '', only: [] do
resources :car_types, path: '', only: [:show] do
end
end
end
end
But the thing is now I would like to also get city either;
/search/nice/weekly/toyota-95
or
/search/france/nice/weekly/toyota-95
The problem is I want to have both with city name and without city name (only country). They should go to same controller which is at the end car_types
.
So if I add car_cities to routes, I get error when there is no city but only country.
namespace :search do
resources :car_countries, path: '', only: [] do
resources :car_cities, path: '', only: [] do
resources :rental_types, path: '', only: [] do
resources :car_types, path: '', only: [:show] do
end
end
end
end
resources :car_countries, path: '', only: [] do
resources :rental_types, path: '', only: [] do
resources :car_types, path: '', only: [:show] do
end
end
end
end
How can I do that?