LoginSignup
0
0

More than 3 years have passed since last update.

¥エンマークをつけて3桁区切りで表す

Posted at

①変数で価格の数値を取得

変数 表示
=@item.price 9768
メソッド 表示
number_to_currency(数値 [, オプション])
= number_to_currency(@item.price) 9,768.00

*コンマがつくが、小数点まで表示される

②小数点以下を消す

メソッド 表示
number_to_currency(数値 [, strip_insignificant_zeros: true])
= number_to_currency(@item.price, strip_insignificant_zeros: true) 9,768

③通貨マークを表示させる

メソッド 表示
number_to_currency(数値 [, strip_insignificant_zeros: true])
= number_to_currency(@item.price, unit: "¥", strip_insignificant_zeros: true) ¥9,768

参考:@Sotq_17さん 感謝です。

https://qiita.com/Sotq_17/items/1e45ff848d8ebab221e5

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