How can I make a url like /united-states/cities/new-york
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 se开发者_如何学编程e new york details)
and how use these routes in views and controllers?
Any ideas how to do this? cheers
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
精彩评论