Skip to content

Commit

Permalink
Fix enterprise model scopes by making ready_for_checkout return enter…
Browse files Browse the repository at this point in the history
…prises and not ids again and by making not_ready_for_checkout select the id field from the ready_for_checkout scope
  • Loading branch information
luisramos0 committed Jun 18, 2019
1 parent b025df1 commit 1da18d3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/models/enterprise.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1da18d3

Please sign in to comment.