How to specify decimal precision in a simple_form number field (Rails) -


Then there is a decimal field with precision 2 in my database, which is meant for currency. It works fine until the last decimal places end in 0, i.e. 799.90 Instead, it will be removed for 79 9.9 when it appears in the field. I know about number_with_precision , but I can not use that helpful method with the simple_form number field because it only takes symbols and HTML options as arguments.

I thought I would need to create a custom input to increase the default number of the simple_form_film, but the syntax appears to not be well documented, so I did not understand how i Number_with_precision can be used to define this custom input.

I essentially want to ask this question that the O.P. What did they want with pharmetics? Thanks!

If you can do it with the settings, then you usually do this with a simple form in your experience can do. Try it out:

  & lt;% = f.input: sales_price ,: input_html = & gt; {Value: number_with_precision (f.object.sales_price, exact: 2)}%>   

If you are using input_field, then you do not need : input_html :

  & lt;% = F.input_field: sales_price, value: number_with_pause (fobbes seal_pres, exact: 2)%>    

Comments