Fix enterprise model scopes by making ready_for_checkout return enterprises and not ids again and by making not_ready_for_checkout select the id field from the ready_for_checkout scope

This commit is contained in:
luisramos0
2019-06-03 16:01:00 +01:00
parent b025df1798
commit 1da18d3386

View File

@@ -111,12 +111,12 @@ class Enterprise < ActiveRecord::Base
joins(:shipping_methods).
joins(:payment_methods).
merge(Spree::PaymentMethod.available).
select('enterprises.id')
select('DISTINCT enterprises.*')
}
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
ready_enterprises = Enterprise.ready_for_checkout.select('enterprises.id')
if ready_enterprises.present?
where("enterprises.id NOT IN (?)", ready_enterprises)
else