0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Railsでカンマ区切り+小数点以下表示で数値を出力する方法

Last updated at Posted at 2020-01-10

目的

整数部をカンマ区切りで表示し、小数点以下を表示したい

コード

number_with_precision(123456789, precision: 2, delimiter: ',')
#=> "123,456,789.00"

参考リンク

ruby-on-rails — 大きな数字にカンマを追加するためのRailsトリックはありますか?
[ActionView::Helpers::NumberHelper]
(https://api.rubyonrails.org/classes/ActionView/Helpers/NumberHelper.html#method-i-number_with_precision)

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?