You can give a name to your route with the as
option :
For example :
get '/companies/city/:city_id', to: 'companies#sort_by_city', as: 'companies_city_sort'
And then use
companies_city_sort_path
Also, have a look at resourceful routing, it may be more adapted.