From 768a170bb818d20df73ab8c53dc002fa86c108ab Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Fri, 3 Aug 2012 08:21:45 +1000 Subject: [PATCH] Fix with_products_on_hand query for server db compatibility --- app/controllers/application_controller.rb | 2 +- app/models/spree/distributor.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index ce006287fc..32d33ac410 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -6,7 +6,7 @@ class ApplicationController < ActionController::Base private def load_data_for_sidebar @suppliers = Spree::Supplier.all - @distributors = Spree::Distributor.with_products_on_hand + @distributors = Spree::Distributor.with_products_on_hand.by_name end end diff --git a/app/models/spree/distributor.rb b/app/models/spree/distributor.rb index b5d033275e..7be94e8a83 100644 --- a/app/models/spree/distributor.rb +++ b/app/models/spree/distributor.rb @@ -13,7 +13,7 @@ module Spree validates_associated :pickup_address scope :by_name, order('name') - scope :with_products_on_hand, joins(:products).where('spree_products.count_on_hand > 0').group('distributors.id') + scope :with_products_on_hand, joins(:products).where('spree_products.count_on_hand > 0').select('distinct(distributors.*)') after_initialize :initialize_country before_validation :set_unused_address_fields