Using Ruby and Haml, I have a property which is cost. I believe (im new to ruby) that it will be a Float
At the moment the below line outputs my decimal in format like 4.5 instead of 4.50, which is what I want.
%span.value= "£#{event.beers.first.cost)}"
This is my class file for beers.
class Beer
include Mongoid::Document
embeds_many :ratings
field :name, type: String
field :country, type: Country
field :cost, type: Float
field :photos, type: PhotoArray, default: PhotoArray.new
end
See the string formatting method, the Kernel::sprintf documentation has all of the arguments for it.
In this case, you would want to do
%span.value= "%%pound;%.2f" % event.beers.first.costto get 4.50 rather than 4.5.