diff --git a/app/controllers/spree/admin/base_controller_decorator.rb b/app/controllers/spree/admin/base_controller_decorator.rb index 1d5d6e476a..6bdd57f0e8 100644 --- a/app/controllers/spree/admin/base_controller_decorator.rb +++ b/app/controllers/spree/admin/base_controller_decorator.rb @@ -52,7 +52,7 @@ Spree::Admin::BaseController.class_eval do def active_distributors_not_ready_for_checkout ocs = OrderCycle.managed_by(spree_current_user).active distributors = ocs.map(&:distributors).flatten.uniq - Enterprise.where('id IN (?)', distributors).not_ready_for_checkout + Enterprise.where('enterprises.id IN (?)', distributors).not_ready_for_checkout end def active_distributors_not_ready_for_checkout_message(distributors) diff --git a/app/models/enterprise.rb b/app/models/enterprise.rb index 3908650eb8..ac9252e389 100644 --- a/app/models/enterprise.rb +++ b/app/models/enterprise.rb @@ -111,14 +111,14 @@ class Enterprise < ActiveRecord::Base joins(:shipping_methods). joins(:payment_methods). merge(Spree::PaymentMethod.available). - select('DISTINCT enterprises.id') + select('enterprises.id') } scope :not_ready_for_checkout, lambda { # When ready_for_checkout is empty, return all rows when there are no enterprises ready for # checkout. ready_enterprises = Enterprise.ready_for_checkout if ready_enterprises.present? - where("id NOT IN (?)", ready_enterprises) + where("enterprises.id NOT IN (?)", ready_enterprises) else where("TRUE") end