小编Mai*_*zki的帖子

Ruby on Rails路由:具有更多参数的命名空间

我有一个名称空间"shop".在该命名空间中,我有一个资源"新闻".

namespace :shop do
  resources :news  
end
Run Code Online (Sandbox Code Playgroud)

我现在需要的是,我的"新闻"路线可以获得一个新参数:

/shop/nike (landing page -> goes to "news#index", :identifier => "nike")
/shop/adidas (landing page -> goes to "news#index", :identifier => "adidas")
/shop/nike/news
/shop/adidas/news
Run Code Online (Sandbox Code Playgroud)

所以我可以得到商店并过滤我的新闻.

我需要一条路线:

/shop/:identfier/:controller/:action/:id
Run Code Online (Sandbox Code Playgroud)

我测试了很多变化,但我不能让它运行.

任何人都可以给我一个提示?谢谢.

ruby routes namespaces ruby-on-rails

5
推荐指数
2
解决办法
5280
查看次数

标签 统计

namespaces ×1

routes ×1

ruby ×1

ruby-on-rails ×1