I'm trying to create a hash using an each loop as follows:
[
hash = session[:cart].each do |product|
price = product[0].price.to_i*100
{
name: product[0].name, description: product[0].description, quantity: product[1], amount: product[0].price
}, #Is it possible to add a comma here? Doing this normally causes an error
end
]
Which should hopefully produce this Output
Output
[
{name: "Hellow", description: "Many Hellows", quantity: 1, price: 1000},
{name: "Hellow", description: "Many Hellows", quantity: 1, price: 1000}
]