Я пытаюсь рассчитать размеры доставки для нескольких продуктов.Я хочу вернуть наибольшее значение @tempLength
и @tempWidth
и суммировать все @tempHeight
с в моем цикле:
@tempLength = 0
@tempWidth = 0
@tempHeight = 0
params[:rate][:items].each do |item|
item = item[:product_id]
puts "Item details"
puts item
@productDimensions = Product.where(:product_id => item).first
@tempLength = @productDimensions.length
@tempWidth = @productDimensions.width
@tempHeight = @productDimensions.height
# tempLength = maximum length value
# tempWidth = maximum width value
# tempHeight = sum of all heights
end
Я знаю, что должен использовать sum(&:symbol)
, но язастрял.Какой лучший подход?