Display 5 instead of 5.00 with decimals

Hi,

Is there a rails wide solution that would show decimals like “5.00” as
“5” in both views and forms?

I guess it would presume overwriting the BigDecimal class, but I have
no idea how.


M.

On Jul 11, 2008, at 5:11 PM, Marcelo B. wrote:

Hi,

Is there a rails wide solution that would show decimals like “5.00” as
“5” in both views and forms?

I guess it would presume overwriting the BigDecimal class, but I have
no idea how.

Not Rails wide, but just use to_i() in your views…

x = 5.00
x.to_i # -> 5

I wouldn’t recommend overriding BigDecimal’s default display…

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs