Hey all, I am working on an app where people can post items for sale.
When they post an item, they add a price to that item.
When the item gets output to the page, it will not display the second
number AFTER the decimal if it is a 0. If it is any other number, it
displays fine. So, prices display as $25.0 if it ends in 0, but $25.95
if it ends in any other number.
Here is the code in my migration to create that column in the database
t.column :price, :decimal, :precision => 8, :scale => 2, :default =>
0, :null => false
I was pretty sure that the :scale => 2 meant two numbers would be
after the decimal, which seems to work fine.
I am then outputting my price in my view with this code…
$<
%= item.price %>
listing, the input field for the price is being pre-populated with
0.0. I would like to remove that as well.
Can anyone shed some light on this for me, as I appear to be missing
something simple!
Thanks!
–Cory