mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Avoid rails 3 bug where the first where clause is overriden by a second where clause
Co-Authored-By: Maikel <maikel@email.org.au>
This commit is contained in:
@@ -88,11 +88,12 @@ Spree::Variant.class_eval do
|
||||
def self.active(currency = nil)
|
||||
# "where(id:" is necessary so that the returned relation has no includes
|
||||
# The relation without includes will not be readonly and allow updates on it
|
||||
where(id: joins(:prices).
|
||||
where(deleted_at: nil).
|
||||
where('spree_prices.currency' => currency || Spree::Config[:currency]).
|
||||
where('spree_prices.amount IS NOT NULL').
|
||||
select("spree_variants.id"))
|
||||
where("spree_variants.id in (?)", joins(:prices).
|
||||
where(deleted_at: nil).
|
||||
where('spree_prices.currency' =>
|
||||
currency || Spree::Config[:currency]).
|
||||
where('spree_prices.amount IS NOT NULL').
|
||||
select("spree_variants.id"))
|
||||
end
|
||||
|
||||
# We override in_stock? to avoid depending on the non-overridable method Spree::Stock::Quantifier.can_supply?
|
||||
|
||||
Reference in New Issue
Block a user