do not show ".0" even for floats
This commit is contained in:
parent
f47413a60f
commit
be76f29473
1 changed files with 17 additions and 0 deletions
17
config/initializers/number_display.rb
Normal file
17
config/initializers/number_display.rb
Normal file
|
@ -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
|
Loading…
Reference in a new issue