Sha256: 7dbf053708ff97c6ddc2bc5d68f1ee55e368cbea94af27579b8cd5140671a9d0
Contents?: true
Size: 503 Bytes
Versions: 6
Compression:
Stored size: 503 Bytes
Contents
class Taxonomy < ActiveRecord::Base validates :name, :presence => true has_many :taxons, :dependent => :destroy has_one :root, :class_name => 'Taxon', :conditions => "parent_id is null" has_one :image, :as => :viewable, :order => :position, :dependent => :destroy 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
6 entries across 6 versions & 5 rubygems