I have a route for querying "Service" model:
resources :services, :path => 'services'
When GET requests for path /services/sn-uber
i take param sn(service name) and find it in database. How to add there another param like sd(service-district)?
For example /services/sn-uber/sd-brooklyn
or /services/sd-brooklyn
so any param could be omitted.
Add something like this to your routes:
get 'services(/sn/:sn_name)(/sd/:sd_name)', controller: 'services', action: 'show'
Your url will look like:
/services/sn/uber/sd/brooklyn
sn_name
and sd_name
/services/sn/uber
sn_name
/services/sd/brooklyn
sd_name
If you want to keep your url like that /services/sn-uber/sd-brooklyn
:
get 'services(/:sn_name)(/:sd_name)', controller: 'services', action: 'show'