繁体   English   中英

Rails,路线映射与正确的动作不匹配

[英]Rails, route mapping not matching the correct action

我正在尝试路由以下网址:

/shop/{category_id}/{product_id}/

到称为“产品”的控制器动作

我的路线上有这个:

match "/shop/:category/:id" => "shop#product" 

而且我有link_to如下:

link_to_unless_current "#{t('murals')}", url_for(:controller => 'shop', :category => 'walls', :id => 'murals')

输出网址时,它们是:

http://0.0.0.0:3000/shop?category=walls&id=murals

而不是所需的:

http://0.0.0.0:3000/shop/walls/murals

如果我切换路线,则转到:

match "/shop/:category/:id" => "shop#index"

这行得通,但这不是正确的操作。

任何帮助,将不胜感激。

尝试这个

<%= link_to_unless_current "#{t('murals')}", custom_path(:category => 'walls', :id => 'murals') %>

match "/shop/:category/:id" => "shop#product", :as => :custom  

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM