Ruby on rails 在FriendlyID slug中隐藏资源名称
我正在使用FriendlyID为我的一些模型制作Slug 要使用FriendlyID文档()中提供的示例,我的URL当前如下所示:Ruby on rails 在FriendlyID slug中隐藏资源名称,ruby-on-rails,routes,friendly-id,Ruby On Rails,Routes,Friendly Id,我正在使用FriendlyID为我的一些模型制作Slug 要使用FriendlyID文档()中提供的示例,我的URL当前如下所示: http://localhost:3000/cities/seattle/restaurants/joes-diner http://localhost:3000/cities/seattle/joes-diner 考虑到在我的例子中,一个城市除了餐馆之外什么都没有,我正在寻找一种方法来删除URL中的“餐馆”部分,使其看起来像这样: http://localho
http://localhost:3000/cities/seattle/restaurants/joes-diner
http://localhost:3000/cities/seattle/joes-diner
考虑到在我的例子中,一个城市除了餐馆之外什么都没有,我正在寻找一种方法来删除URL中的“餐馆”部分,使其看起来像这样:
http://localhost:3000/cities/seattle/restaurants/joes-diner
http://localhost:3000/cities/seattle/joes-diner
或者如果可能的话
http://localhost:3000/seattle/joes-diner
如果这样做是明智的,那么实现这一目标的最佳方法是什么?我可以想象,最后一个选项可能会带来一些麻烦。您可以在中找到解决问题的方法 您可以为此任务使用
:path=>“”
问候 带有规格和正确的编辑\更新等的解决方案。此处的slug:
您看过命名路线了吗?