class Category < ActiveRecord::Base
has_many :children, :class_name => 'Category', :foreign_key => 'parent_id'
belongs_to :parent, :class_name => 'Category'
has_many :products
end
class Product < ActiveRecord::Base
belongs_to :category
end
@category = Category.find(1)
# 怎么样能让这里获取这个分类及其子分类下的所有 products?
@category.products