Text field does not always display 2 decimal places

Confused Rails 3 newbie.

My goal is to have a simple Rails 3 app where I can view and edit a
price value. You can view my source code here
(https://github.com/michaelklem/Money-Test). My model has a
purchase_price attribute defined like this:

t.decimal :purchase_price, :precision => 12, :scale => 2, :default =>
0.00

I defined a custom getter in the model to force 2 decimal places to
always exist.

def purchase_price
sprintf( “%.2f”,attributes[‘purchase_price’])
end

This works correctly from the console and when I display the show page.
On the edit page I have a text field to edit this value. My problem is
that if this value is saved as ‘123.00’ the value is displayed as
‘123.0’.

Current Status
Decimal value as stored in MySQL: 100.20
Value returned from console: 100.20
Value displayed in text field: 100.2
Value returned via Firebug: “100.2”
The text field length is not an issue.
If the value in the db is 100.21, it is displayed correctly as 100.21

Questions
Why is my custom getter not getting called?
Why is this displayed with 1 decimal and not 2 decimals?

Thanks

I got a solution from stackoverflow.com.

I was unaware of this format to control how the values are displayed:

<%= f.text_field :current_price,
:value=>number_to_currency(f.object.current_price, :unit=>‘’), :class =>
“currency” %>

I was able to remove this code:

def purchase_price
sprintf( “%.2f”,attributes[‘purchase_price’])
end