①変数で価格の数値を取得
| 変数 | 表示 |
|---|---|
| =@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さん 感謝です。