0
1

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 5 years have passed since last update.

金額や数値をカンマ区切りにしたい場合、JPYしか扱わないなら to_s(:delimited) を使うと楽

0
Last updated at Posted at 2018-07-25

ActiveSupport::NumberHelper#number_to_currency もあるけど、すこし不便

ActiveSupport::NumericWithFormat#to_s(:delimited)ならシンプル

数値を(デフォルトでは)カンマ区切りにしてくれる

.ruby
1000000.to_s(:delimited) # => "1,000,000"

日本円をカンマ区切りにしたいならば、以下のようにすれば良い

.ruby
1000000.to_s(:delimited) + '円' # => "1,000,000円"

JPYしか扱わないなら、こっちのほうがシンプル

0
1
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
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?