我对rails中的路线有疑问。
在我的新项目中,我的模型名称为
1. Country
2. States
3. Category
4. Subcategory
5. advertisements
我想生成如下路线
1. /en
2. /en/advertisements
3. /en/indiana
4. /en/indiana/advertisements
5. /en/indiana/cars
6. /en/indiana/cars/advertisements
7. /en/indiana/cars/bmw/advertisements
8. /en/cars/advertisements
前任 :-
en is country locale
indiana is state
cars is category
bmw is sub category
这是我在 routes.rb 中的路由声明
scope ":language" do <br />
scope "(:state)" do <br />
scope "(:main_category)" do <br />
scope "(:category)" do <br />
resources :advertisements <br />
match "search" => "advertisements#index"
<br /> end<br />
end<br />
end<br />
end <br />
如果 url 是“/en/indiana/cars/bmw/advertisements”,上述路线可以正常工作
现在我想要“/en/cars/advertisements”“/en/cars/advertisements”的路线,然后它将分配 en 到语言和汽车状态
我如何声明此“/en/cars/advertisements”的路线,
请帮帮我
提前致谢