如何使用货币轨道以符号显示价格 [英] how to display price with symbol using money-rails

查看:66
本文介绍了如何使用货币轨道以符号显示价格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给出这个简单的 Money 对象查询

Given this simple Money object query

Money.new(1000, "USD").to_s
=> "10.00" 

如何显示带有符号的值?我知道我可以调用 money_object.symbol ,但是有些货币将符号放在值的前面,而其他货币则放在值的后面。我很确定应该已经有一些简单的方法了吗?尚未通过阅读文档找到它。

How can I display the value with its symbol? I'm aware I can call money_object.symbol but some currencies place the symbol before and other after the value. Im pretty sure there should be some easy method already for this? Haven't find it by reading into the documentation.

推荐答案

ActionView :: Helpers :: NumberHelper 具有 number_to_currency 应该可以技巧。

这篇关于如何使用货币轨道以符号显示价格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆