重複の可能性:
Rails で自己結合テーブルを結合できない
マルチレベルのカテゴリがあります
class Category < ActiveRecord::Base
  belongs_to :parent, :class_name => "Category", :foreign_key => "parent_id"
  has_many :children,  :class_name => "Category"
  has_many :products
  attr_accessible :description, :title, :parent
end
ここにのモデルがありますProduct
class Product < ActiveRecord::Base
  belongs_to :category
end
Product親カテゴリ名ですべての製品を検索できるように、スコープを定義する必要があります
class Product < ActiveRecord::Base
 #.....
 #scope :of_tea, lambda{ where(:category.parent.name => "tea") } # not working
end