mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-11 23:17:48 +00:00
Apply suggestions from code review
Rails is clever enough to not query the database without ids Co-authored-by: Maikel <maikel@email.org.au>
This commit is contained in:
@@ -20,10 +20,9 @@ module Sets
|
||||
end
|
||||
|
||||
def collection_attributes=(attributes)
|
||||
ids = attributes.each_value.map { |product| product[:id] }.compact
|
||||
@collection = []
|
||||
ids = attributes.values.pluck(:id).compact
|
||||
# Find and load existing products in the order they are provided
|
||||
@collection = Spree::Product.find(ids) if ids.present?
|
||||
@collection = Spree::Product.find(ids)
|
||||
@collection_hash = attributes
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user