From 20f951d7d01c0f9b9d843d0b9f1187c658398896 Mon Sep 17 00:00:00 2001 From: Rafael Martins Date: Wed, 14 Mar 2012 16:37:12 -0300 Subject: [PATCH] Bugfix map ballon and facet sorting --- app/controllers/public/map_balloon_controller.rb | 6 ++++-- app/helpers/search_helper.rb | 2 +- lib/acts_as_faceted.rb | 8 ++------ lib/set_profile_region_from_city_state.rb | 2 ++ 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/controllers/public/map_balloon_controller.rb b/app/controllers/public/map_balloon_controller.rb index 69e95cf..0d68b8a 100644 --- a/app/controllers/public/map_balloon_controller.rb +++ b/app/controllers/public/map_balloon_controller.rb @@ -1,6 +1,8 @@ class MapBalloonController < PublicController - before_filter :profile, :only => [:person, :enterprise, :community] + helper SearchHelper + + before_filter :load_profile, :only => [:person, :enterprise, :community] def product @product = Product.find(params[:id]) @@ -21,7 +23,7 @@ class MapBalloonController < PublicController protected - def profile + def load_profile @profile = Profile.find(params[:id]) end diff --git a/app/helpers/search_helper.rb b/app/helpers/search_helper.rb index 1565959..966c387 100644 --- a/app/helpers/search_helper.rb +++ b/app/helpers/search_helper.rb @@ -131,7 +131,7 @@ module SearchHelper def order_by(asset) options = { - :products => [[_('Relevance'), ''], [_('More Recent'), 'updated_at desc'], [_('Name'), 'name_or_category_sort asc'], [_('Lower price'), 'price_sort asc'], [_('Higher price'), 'price_sort desc']], + :products => [[_('Relevance'), ''], [_('More Recent'), 'updated_at desc'], [_('Name'), 'name_or_category_sort asc']], :events => [[_('Relevance'), ''], [_('Name'), 'name_sort asc']], :articles => [[_('Relevance'), ''], [_('Name'), 'name_sort asc'], [_('Most recent'), 'updated_at desc']], :enterprises => [[_('Relevance'), ''], [_('Name'), 'name_sort asc']], diff --git a/lib/acts_as_faceted.rb b/lib/acts_as_faceted.rb index 58f06de..71a7fd3 100644 --- a/lib/acts_as_faceted.rb +++ b/lib/acts_as_faceted.rb @@ -134,13 +134,9 @@ module ActsAsFaceted if facet[:queries_order] facets_data elsif sort_by == :alphabetically - facets_data.sort do |a,b| - a = a[1].is_a?(String) ? a[1] : a.first - b = b[1].is_a?(String) ? b[1] : b.first - a <=> b - end + facets_data.sort{ |a,b| Array(a[1])[0] <=> Array(b[1])[0] } elsif sort_by == :count - facets_data.sort{ |a,b| -1*(a[2] <=> b[2]) } + facets_data.sort{ |a,b| -1*(a[2] <=> b[2]) } else facets_data end diff --git a/lib/set_profile_region_from_city_state.rb b/lib/set_profile_region_from_city_state.rb index cf24d3f..24964f4 100644 --- a/lib/set_profile_region_from_city_state.rb +++ b/lib/set_profile_region_from_city_state.rb @@ -28,6 +28,8 @@ module SetProfileRegionFromCityState if s c = City.find_by_contents(self.city, {}, :filter_queries => ["parent_id:#{s.id}"])[:results].first self.region = c + else + self.region = nil end end end -- libgit2 0.21.2