Commit 889466873f3690c273936ca544742748c4dfdea1
1 parent
f927bc53
Exists in
master
and in
29 other branches
ActionItem25: indexing products by their full category name
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@1040 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
2 changed files
with
4 additions
and
5 deletions
Show diff stats
app/models/product.rb
@@ -10,10 +10,10 @@ class Product < ActiveRecord::Base | @@ -10,10 +10,10 @@ class Product < ActiveRecord::Base | ||
10 | 10 | ||
11 | after_update :save_image | 11 | after_update :save_image |
12 | 12 | ||
13 | - acts_as_searchable :fields => [ :name, :description, :category_name ] | 13 | + acts_as_searchable :fields => [ :name, :description, :category_full_name ] |
14 | 14 | ||
15 | - def category_name | ||
16 | - product_category.name | 15 | + def category_full_name |
16 | + product_category.full_name(" ") | ||
17 | end | 17 | end |
18 | 18 | ||
19 | def image_builder=(img) | 19 | def image_builder=(img) |
lib/acts_as_filesystem.rb
@@ -58,8 +58,7 @@ module ActsAsFileSystem | @@ -58,8 +58,7 @@ module ActsAsFileSystem | ||
58 | # | 58 | # |
59 | # Then Category "C" will have "A/B/C" as its full name. | 59 | # Then Category "C" will have "A/B/C" as its full name. |
60 | def full_name(sep = '/') | 60 | def full_name(sep = '/') |
61 | - my_name = self.name ? self.name : '?' | ||
62 | - self.parent ? (self.parent.full_name(sep) + sep + my_name) : (my_name) | 61 | + self.hierarchy.map {|item| item.name || '?' }.join(sep) |
63 | end | 62 | end |
64 | 63 | ||
65 | # calculates the level of the category in the category hierarchy. Top-level | 64 | # calculates the level of the category in the category hierarchy. Top-level |