Sha256: 365675c34f8c609db9cb17d7f2ff489172f8d2dc6efb9ff7181f8d891ffcf21b
Contents?: true
Size: 381 Bytes
Versions: 9
Compression:
Stored size: 381 Bytes
Contents
class Taxonomy < ActiveRecord::Base has_many :taxons, :dependent => :destroy has_one :root, :class_name => 'Taxon', :conditions => "parent_id is null" def after_save 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