Sha256: 8d01f6a017eaebd47932265e2c4e92003bfe6ee46e3b359b9fa1a56f883099b3

Contents?: true

Size: 395 Bytes

Versions: 1

Compression:

Stored size: 395 Bytes

Contents

class Category < ActiveRecord::Base
  has_many :products
  acts_as_list :scope => :parent_id
  acts_as_tree :order => :position
  validates_presence_of :name
  
  def ancestors_name
    if parent
      parent.ancestors_name + parent.name + ':'
    else
      ""
    end
  end

  def long_name
    ancestors_name + name
  end
  
  def before_save
    self.parent = nil if parent == self
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
spree-0.2.0 app/models/category.rb