1 require 'dm-validations'
5 include DataMapper::Resource
6 include DataMapper::Validate
7 #include DataMapper::Is::Tree
9 property :id, Fixnum, :serial => true
10 property :name, String, :length => 100, :nullable => false, :key => :unique
11 property :rank, Fixnum
12 property :parent_id, Fixnum
14 #many_to_many :products #, :join_table => 'products_tags'
15 validates_presence_of :name
16 validates_uniqueness_of :rank
19 all(:order => [ :name.asc ])
23 all(:conditions => [:parent_id => 0], # parent_id => nil,
24 :order => [ :rank.desc ])