Following were my HomeController:
def index
@products = Product.public_active
.order('random()')
.limit(6)
.includes(:product_attachments)
.includes(:product_reviews)
@products.each do |product|
if product.currency != session[:currency]
if session["currency-convert-#{product.currency}"].to_f == 0.0
rate = 1.0
else
rate = session["currency-convert-#{session[:currency]}"].to_f /
session["currency-convert-#{product.currency}"].to_f
end
else
rate = 1.0
end
product.price_with_currency = 300.00
product.current_currency = session[:currency]
end
end
And here is my View:
<div id="product-list">
<div class="row">
<p class="price"><%= product.price_with_currency %></p>
</div>
</div>
The issues is, price_with_currency
output the result of 300.0
not 300.00
. Why it is so? Thanks!!