diff --git a/app/models/product.rb b/app/models/product.rb index 377595b..e1f29a9 100644 --- a/app/models/product.rb +++ b/app/models/product.rb @@ -10,10 +10,10 @@ class Product < ActiveRecord::Base after_update :save_image - acts_as_searchable :fields => [ :name, :description, :category_name ] + acts_as_searchable :fields => [ :name, :description, :category_full_name ] - def category_name - product_category.name + def category_full_name + product_category.full_name(" ") end def image_builder=(img) diff --git a/lib/acts_as_filesystem.rb b/lib/acts_as_filesystem.rb index 9b98a2a..82a491f 100644 --- a/lib/acts_as_filesystem.rb +++ b/lib/acts_as_filesystem.rb @@ -58,8 +58,7 @@ module ActsAsFileSystem # # Then Category "C" will have "A/B/C" as its full name. def full_name(sep = '/') - my_name = self.name ? self.name : '?' - self.parent ? (self.parent.full_name(sep) + sep + my_name) : (my_name) + self.hierarchy.map {|item| item.name || '?' }.join(sep) end # calculates the level of the category in the category hierarchy. Top-level -- libgit2 0.21.2