I'm trying to display a numeric attribute of a model as a currency on a form, and then save the user's input. So the text field might display '$9.98' and the user is allowed to enter dollar signs. How can I remove the dollar sign before saving to the db and still display the user's original input string in error messages?
My template file looks like this:
<%= text_field("winning", "amount", :value => number_to_currency(@winning.amount) %>
I tried manually removing the dollar signs from the values in the params hash before applying them to the models (via update_attributes) but then the models don't have the user's original inputs, and I'm using the error_messages_for tag to display the errors. I was also trying to avoid hacking presentation format knowledge into the model object if possible.
Any ideas?
Thanks!
Steve