Class: Taxon

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
ProductFilters
Defined in:
app/models/taxon.rb

Instance Method Summary collapse

Methods included from ProductFilters

all_taxons, brand_filter, price_filter, selective_brand_filter, taxons_below

Instance Method Details

#applicable_filtersObject



20
21
22
23
24
25
26
27
28
# File 'app/models/taxon.rb', line 20

def applicable_filters
  fs = []
  # fs << ProductFilters.taxons_below(self)
  ## unless it's a root taxon? left open for demo purposes
  
  fs << ProductFilters.price_filter if ProductFilters.respond_to?(:price_filter)
  fs << ProductFilters.brand_filter if ProductFilters.respond_to?(:brand_filter)
  fs
end

Creates permalink based on .to_url method provided by stringx gem



31
32
33
34
35
36
37
38
# File 'app/models/taxon.rb', line 31

def set_permalink
  if parent_id.nil?
    self.permalink = name.to_url + "/" if self.permalink.blank?
  else
    parent_taxon = Taxon.find(parent_id)
    self.permalink = parent_taxon.permalink + (self.permalink.blank? ? name.to_url : self.permalink.split("/").last) + "/"
  end
end