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



19
20
21
22
23
24
25
26
# File 'lib/forge/app/models/product_category.rb', line 19

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



28
29
30
# File 'lib/forge/app/models/product_category.rb', line 28

def path
  parents.join('/')
end

#validate_destroyObject



15
16
17
# File 'lib/forge/app/models/product_category.rb', line 15

def validate_destroy
  products.count < 1
end