I am building a shopping cart app in rails. CartItems model has a column for quantity of the type integer and a column for cart_price of the type decimal. For each item added to the cart a new row is added to the database Model name CartItems. The controller retrieves quantity and price successfully. But when multiplying I receive the error message above. Once the multiplication works I want to add the products together to get the subtotal for the cart.
def subtotal
@cart_content = @cart_item.pluck(:quantity,:cart_price)
@subtotal = @cart_content.inject(:*)
end
When I remove .inject(:*) from @subtotal the controller retrieves the correct data.
Example output from view for two products, with quantity and price value present
[[3, #BigDecimal:7fc9a9b2d980,'0.1285E3',18(36)>], [1, # BigDecimal:7fc9a9b2d7c8,'0.115E3',9(27)>]]
@cart_item?