Fix with_products_on_hand query for server db compatibility

This commit is contained in:
Rohan Mitchell
2012-08-03 08:21:45 +10:00
parent 8834268970
commit 768a170bb8
2 changed files with 2 additions and 2 deletions

View File

@@ -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

View File

@@ -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