Sha256: 2c46e1b5069c687a584f4279c82c4418c805aaa0e813dafb4973775fbb8308e2
Contents?: true
Size: 567 Bytes
Versions: 14
Compression:
Stored size: 567 Bytes
Contents
module Spree class Taxonomy < ActiveRecord::Base validates :name, presence: true attr_accessible :name has_many :taxons has_one :root, conditions: { parent_id: nil }, class_name: "Spree::Taxon", dependent: :destroy after_save :set_name default_scope order: "#{self.table_name}.position" private def set_name if root root.update_column(:name, name) else self.root = Taxon.create!({ taxonomy_id: id, name: name }, without_protection: true) end end end end
Version data entries
14 entries across 14 versions & 1 rubygems