I have this edit form.
But when I store something such as 1.5, I would like to display it as 1.50.
How could I do that with the form helper? <%= f.text_field :cost, :class => 'cost' %>
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You should use
number_with_precisionhelper. See doc.Example:
Within you form helper:
BTW, if you really want to display some price, use
number_to_currency, same page for doc (In a form context, I’d keepnumber_with_precision, you don’t want to mess up with money symbols)