Rails 3. How to display two decimal places in edit form?

前端 未结 4 2017

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.

4条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-04 13:24

    Alternatively, you can use the format string "%.2f" % 1.5. http://ruby-doc.org/docs/ProgrammingRuby/html/ref_m_kernel.html#Kernel.sprintf

提交回复
热议问题