2012-06-18 40 views
1

我使用FriendlyID为我的一些模型生成slu gs。在FriendlyID slug中隐藏资源名称

要使用在FriendlyID文档(http://rubydoc.info/github/norman/friendly_id/master/frames)提供的例子,我的网址目前是这样的:

http://localhost:3000/cities/seattle/restaurants/joes-diner 

考虑到我的情况,一个城市就没有什么,但餐厅,我寻找一种方法,以消除在URL中的“餐馆”位,这样它看起来像这样:

http://localhost:3000/cities/seattle/joes-diner 

或者如果可能的话甚至

http://localhost:3000/seattle/joes-diner 

达到此目的的最佳方法是什么 - 如果最好这样做?我可以想象,最后的选择可能会产生一些复杂性。

+1

你看着一个名为路线了吗? [官方文档在这里](http://guides.rubyonrails.org/routing.html) –

回答