テーブル構造とデータがあるカテゴリと呼ばれるテーブルがあります
id | parent_id | name
------------------------
1 | 0 | Computers // parent
2 | 0 | TV // parent
4 | 1 | Motherboards // child - to - id(1)
5 | 4 | Mercury
6 | 5 | Mecrury XXX
7 | 6 | Mecrury YYY
(ここで、parent_idは別の行のIDです)
Rails3 Activerecord query interfaceを使用して親子の結果を取得する方法を示します。(またはその他のソリューション)。
コンピューターを検索すると、すべての子を取得するにはどうすればよいですか->その親カテゴリの下のスーパーチャイルド。
Example Result will - Computers -> Motherboards -> Mercury XXX -> Mercury YYY
ありがとうございました