i have a model
class Category < ActiveRecord::Base
belongs_to :parent, :class_name => 'Category'
has_many :children, :class_name => 'Category', :foreign_key => 'parent_id'
end
I want to a Scope with select all Category in tables categories with category.children == nil
or (category.children.count == 0)
.
Pls help me.
Aucun commentaire:
Enregistrer un commentaire