开发者

In Rails, How to parse a category and sub category url structure

Say I have my urls like:

www.example.com/categories/category1/subcategory1

My database would have a table Categories:

ID NAME parentID 1 category1 -1 2 subcategory1 1

So I would need to load both category ID 1 and 2 since that is what is being displayed.

I know my explanation isn't that clear, but I hope what I am after is!

OH, and how would this route be开发者_运维百科 setup, since there could be an unlimited # of category/subcategory/sub-subcateogry levels.


http://guides.rubyonrails.org/routing.html#nested-resources

Following convention over configuration:

Resources should never be nested more than 1 level deep.

The rest of those guides are a good read.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜