Commit 3b669432f54eb1dc7d37cd0e1bfa21f82a528c31
1 parent
bed30d50
Exists in
master
and in
29 other branches
Fix for 'set_profile_region_from_city_state' when state is not found
Solr boost for Category name field
Showing
2 changed files
with
4 additions
and
2 deletions
Show diff stats
app/models/category.rb
@@ -15,6 +15,8 @@ class Category < ActiveRecord::Base | @@ -15,6 +15,8 @@ class Category < ActiveRecord::Base | ||
15 | 15 | ||
16 | acts_as_filesystem | 16 | acts_as_filesystem |
17 | 17 | ||
18 | + acts_as_searchable :additional_fields => [{:name => {:boost => 2.0}}] | ||
19 | + | ||
18 | has_many :article_categorizations | 20 | has_many :article_categorizations |
19 | has_many :articles, :through => :article_categorizations | 21 | has_many :articles, :through => :article_categorizations |
20 | has_many :comments, :through => :articles | 22 | has_many :comments, :through => :articles |
lib/set_profile_region_from_city_state.rb
@@ -24,9 +24,9 @@ module SetProfileRegionFromCityState | @@ -24,9 +24,9 @@ module SetProfileRegionFromCityState | ||
24 | 24 | ||
25 | def region_from_city_and_state | 25 | def region_from_city_and_state |
26 | if @change_region | 26 | if @change_region |
27 | - s = State.find_by_name self.state | 27 | + s = State.find_by_contents(self.state)[:results].first |
28 | if s | 28 | if s |
29 | - c = s.children.find_by_name self.city | 29 | + c = City.find_by_contents(self.city, {}, :filter_queries => ["parent_id:#{s.id}"])[:results].first |
30 | self.region = c | 30 | self.region = c |
31 | end | 31 | end |
32 | end | 32 | end |