Title: How can I make a url like /united-states/cities/new-york
Tags: ruby-on-rails;routing;rest;url-routing
Question: How can I make a url like "/united-states/cities/new-york" intead of "/countries/1/cities/1" (I dont't want the word "countries" in the url)
what do I have to write in route.rb to use:
site.com/united-states/cities/ (to see united states' cities list)
site.com/united-states/cities/new-york/ (to see new york details)
and how use these routes in views and controllers?
Any ideas how to do this? cheers
Comment: I've found the rails guide on routing pretty useful: http://guides.rubyonrails.org/routing.html  I think what you are looking for is in section 4 Regular Routes.


Here is another answer: http://railscasts.com/episodes/63-model-name-in-url
class Country
def to_param
@name
end
class CountryController
def show
@country = Country.find(:name =&gt; param[:id])
# ...
end
Comment for this answer: thanks Maciej but I still confused with:
what do I have to write in route.rb to use:
site.com/united-states/cities/ (to see united states' cities list)
site.com/united-states/cities/new-york/ (to see new york details)
and how use these routes in views and controllers?
Comment for this answer: Sorry for delay. You set up the routes normally - only changes are in controller/model. All in detail is in podcast (link given).

{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 1, 'ContentLicense': 'CC BY-SA 2.5', 'CreationDate': '2010:00:03/12/10', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<ruby-on-rails><routing><rest><url-routing>', 'Title': 'How can I make a url like /united-states/cities/new-york', 'ViewCount': 115, 'id': 2429586, 'user_AboutMe': None, 'user_AccountId': None, 'user_DisplayName': None, 'user_Reputation': None, 'user_Views': None, 'user_id': None}}