我有一个模型类别:
class Category < ActiveRecord::Base
has_many :item_categories, :dependent => :destroy
has_many :items, :through => :item_categories
has_ancestry
end
和型号项目:
class Item < ActiveRecord::Base
has_many :item_categories, :dependent => :destroy
has_many :categories, :through => :item_categories, :uniq => true
end
我使用这个宝石 - https://github.com/stefankroes/ancestry
因此,网站上的 URL 可以是:
/category-slug/ - "categories#show"
/category-slug/subcategory-slug
/category-slug/subcategory-slug/subsubcategory-slug
/category-slug/item-slug - "items#show"
/category-slug/subcategory-slug/item-slug
/category-slug/subcategory-slug/subsubcategory-slug/item-slug
这个网址的路线看起来如何?这可能吗?