Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/58.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 在FriendlyID slug中隐藏资源名称_Ruby On Rails_Routes_Friendly Id - Fatal编程技术网

Ruby on rails 在FriendlyID slug中隐藏资源名称

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

我正在使用FriendlyID为我的一些模型制作Slug

要使用FriendlyID文档()中提供的示例,我的URL当前如下所示:

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:


您看过命名路线了吗?