1
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 1 year has passed since last update.

【Ruby on Rails】number_to_currencyの使い方

Posted at

number_to_currencyの使い方メモ
これを直訳すると、数値から通貨へということらしい。

<span class="gorira"><%= number_to_currency(cart_item.price_total, unit: "¥", strip_insignificant_zeros: true) %></span>

第一引数に金額 cart_itemモデルに合計金額を表示させるためのprice_totalメソッドを書いたのでそれを上では使用
第二引数に通貨の単位 $とかも使えるらしいけど、日本なので¥とした
第三引数に小数点の非表示化 defaultはfalseになるが非表示としたいので、trueにする

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