mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Fix PG::UndefinedTable errors
The logic of #includes has changed slightly in Rails 4.2 and now usually needs the #references method as well.
PG::UndefinedTable:
# ERROR: missing FROM-clause entry for table "enterprises"
# LINE 1: SELECT "spree_users".* FROM "spree_users" WHERE (enterprises...
# ^
# ./spec/models/spree/user_spec.rb:125:in `block (4 levels) in <top (required)>'
This commit is contained in:
@@ -60,7 +60,10 @@ module OpenFoodNetwork
|
||||
def filter_to_supplier(orders)
|
||||
if params[:supplier_id].to_i > 0
|
||||
orders.select do |order|
|
||||
order.line_items.includes(:product).references(:product).where("spree_products.supplier_id = ?", params[:supplier_id].to_i).count > 0
|
||||
order.line_items.includes(:product)
|
||||
.where("spree_products.supplier_id = ?", params[:supplier_id].to_i)
|
||||
.references(:product)
|
||||
.count > 0
|
||||
end
|
||||
else
|
||||
orders
|
||||
|
||||
Reference in New Issue
Block a user