Class: ProductCategory

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
Forge::Reorderable
Defined in:
lib/forge/app/models/product_category.rb

Instance Method Summary collapse

Methods included from Forge::Reorderable

included

Instance Method Details

#parents(category = self) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/forge/app/models/product_category.rb', line 16

def parents( category=self )
  #Probably need to modify this to use slug instead of title?  At least parameterize things.
  if category.parent.nil?
    return [category.title]
  else
    return parents(category.parent).concat([category.title])
  end
end

#pathObject



25
26
27
# File 'lib/forge/app/models/product_category.rb', line 25

def path
  parents.join('/')
end

#validate_destroyObject



12
13
14
# File 'lib/forge/app/models/product_category.rb', line 12

def validate_destroy
  products.count < 1
end