2013-08-12 212 views
-1

我使用rails 3.2ruby 1.9.3 我使用这显示价格字符串的比较:number_to_currency轨失败,0失败

number_to_currency(12.0) 

在区域设置:zh,它的作品,但在:ES我得到: comparison of String with 0 failed

没有找到它在任何地方,任何人?

编辑:我已经更新了数仅仅是明确的,数量是合法的,问题是语言环境

+0

结帐此http://stackoverflow.com/questions/10842529/number-with-precision-return-integer。还要检查返回值的类的顺序[:base_price],'1'> 0将失败,并出现错误:比较字符串与0失败 – dotcomXY

+0

嗨@dotcomXY,我已编辑问题 – devmonster

回答

1

当语言环境文件实际存在时,可能会出现此错误的另一种解释。

确保数字不在您的区域设置文件中引用。

es: 
    number: 
    currency: 
     precision: 2 # correct 
     precision: "2" # that would be wrong