2011-03-04 57 views
2

这是我用来显示一个“财产”的价格代码:Rails的转换为货币问题

<%= number_to_currency(@property.price) %> 

什么,我希望做的是通过划分这个number_to_currency转换的结果4获得每周价格(而不是每月价格)

感谢您的帮助

回答

3

<%= number_to_currency(@property.price/4) %>

这是否不行?

+0

是的,它做到了。谢谢。我正在尝试:(number_to_currency(@ listing.price))/ 4,这没有奏效。我的一个语法错误。感谢您的回答! – hanumanDev 2011-03-04 11:40:15

+1

如果你试图做number_to_currency(@ property.price)/ 4你试图分割字符串。另一种选择是在你的模型中定义一个称为每周价格的虚拟属性,返回价格/ 4。 – Doon 2011-03-04 11:42:53