1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-02-20 14:54:15 +01:00

(bug) order by price with unset prices

In product ordering, consider NULL prices (no price has been defined) as 0, to
order those products as lowest prices items
This commit is contained in:
Sylvain 2022-09-27 11:50:35 +02:00
parent 1c5abf663d
commit e687e8ad02

View File

@ -126,7 +126,11 @@ class ProductService
key ||= 'created_at'
order ||= 'desc'
products.order(key => order)
if key == 'amount'
products.order("COALESCE(amount, 0) #{order.upcase}")
else
products.order(key => order)
end
end
end
end