Sha256: 331baee9bdf45c9e4012fd6778facba981e92eba5a10c49fc6676a4b9b33ee8b
Contents?: true
Size: 422 Bytes
Versions: 9
Compression:
Stored size: 422 Bytes
Contents
class Taxonomy < ActiveRecord::Base validates :name, :presence => true has_many :taxons, :dependent => :destroy has_one :root, :class_name => 'Taxon', :conditions => {:parent_id => nil} after_save :set_name private def set_name if self.root self.root.update_attribute(:name, self.name) else self.root = Taxon.create!({ :taxonomy_id => self.id, :name => self.name }) end end end
Version data entries
9 entries across 9 versions & 1 rubygems