私のテーブルは:
| 1 | Electronics | Cameras
| 2 | Electronics | Computers
| 3 | Electronics | Mobile Phone
| 4 | Electronics | Sound & Vision
| 5 | Clothes | womens clothing
| 7 | Clothes | women shoes
| 8 | Clothes | women hand bags
| 9 | Clothes | Mens clothing
| 10 | Clothes | Kids clothing
インデックスページに次のようなリンクを表示しようとしています。
**Electronics**
Computers
Mobile Phone
Sound & Vision
**Clothes**
womens clothing
women shoes
Mens clothing
どうすればこれを行うことができますか?
私のモデルは次のようなものです。
class Category < ActiveRecord::Base
has_many :products
attr_accessible :division,:subdivision
end
class Product < ActiveRecord::Base
has_many :photos,:dependent => :destroy
has_many :line_items, :through => :product_id
belongs_to :merchant
belongs_to :category
attr_accessor :quantity
accepts_nested_attributes_for :photos, :line_items
カテゴリテーブルは親であり、製品にはがありcategory_id
ます。上記の方法でカテゴリを表示したいのは、商品があり、商品モデルが次のようになっている場合のみです。
リンクをクリックするとリンクが表示されたら、関連するすべての商品を表示する予定です。
製品のあるカテゴリを表示する方法を教えてもらえますか?