views:

60

answers:

1

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

+1  A: 

http://railscasts.com/episodes/63-model-name-in-url

class Country
    def to_param
        @name
    end
end

class CountryController
    def show
        @country = Country.find(:name => param[:id])
        # ...
    end
end
Maciej Piechotka
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?
Matias
Sorry for delay. You set up the routes normally - only changes are in controller/model. All in detail is in podcast (link given).
Maciej Piechotka