From be76f29473eafc872233dbe54eb576b5f8c76289 Mon Sep 17 00:00:00 2001 From: wvengen Date: Sat, 14 Dec 2013 00:19:18 +0100 Subject: [PATCH] do not show ".0" even for floats --- config/initializers/number_display.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 config/initializers/number_display.rb diff --git a/config/initializers/number_display.rb b/config/initializers/number_display.rb new file mode 100644 index 00000000..666f5147 --- /dev/null +++ b/config/initializers/number_display.rb @@ -0,0 +1,17 @@ +# we'd like to show "0.0" as "0" + +class Float + alias :foodsoft_to_s :to_s + def to_s + foodsoft_to_s.chomp(".0") + end +end + +if defined? BigDecimal + class BigDecimal + alias :foodsoft_to_s :to_s + def to_s + foodsoft_to_s.chomp(".0") + end + end +end