【发布时间】:2012-06-20 10:30:54
【问题描述】:
我正在使用 FriendlyID 为我的一些模型生成 slug。
要使用 FriendlyID 文档 (http://rubydoc.info/github/norman/friendly_id/master/frames) 中提供的示例,我的网址目前如下所示:
http://localhost:3000/cities/seattle/restaurants/joes-diner
鉴于在我的情况下,一个城市除了餐馆什么都没有,我正在寻找一种方法来删除 URL 中的“restaurants”位,使其看起来像这样:
http://localhost:3000/cities/seattle/joes-diner
或者如果可能的话
http://localhost:3000/seattle/joes-diner
实现这一目标的最佳方法是什么 - 如果这样做是可取的?我可以想象最后一个选项可能会带来一些复杂性。
【问题讨论】:
-
你看过命名路线了吗? Official doc is here
标签: ruby-on-rails routes friendly-id