diff --git a/app/controllers/spree/admin/base_controller.rb b/app/controllers/spree/admin/base_controller.rb index 67a44ad093..7591e1b3ce 100644 --- a/app/controllers/spree/admin/base_controller.rb +++ b/app/controllers/spree/admin/base_controller.rb @@ -97,7 +97,7 @@ module Spree def active_distributors_not_ready_for_checkout ocs = OrderCycle.managed_by(spree_current_user).active distributors = ocs.includes(:distributors).map(&:distributors).flatten.uniq - Enterprise.where('enterprises.id IN (?)', distributors).not_ready_for_checkout + Enterprise.where(id: distributors.map(&:id)).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 ff95102781..381613aaa0 100644 --- a/app/models/enterprise.rb +++ b/app/models/enterprise.rb @@ -115,7 +115,7 @@ class Enterprise < ActiveRecord::Base 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.select('enterprises.id') + ready_enterprises = Enterprise.ready_for_checkout.pluck(:id) if ready_enterprises.present? where("enterprises.id NOT IN (?)", ready_enterprises) else diff --git a/app/models/order_cycle.rb b/app/models/order_cycle.rb index b26625fe68..9a30c493e5 100644 --- a/app/models/order_cycle.rb +++ b/app/models/order_cycle.rb @@ -63,7 +63,7 @@ class OrderCycle < ActiveRecord::Base if user.has_spree_role?('admin') scoped else - where('coordinator_id IN (?)', user.enterprises.map(&:id)) + where(coordinator_id: user.enterprises) end }