分享 rails 遇到的一个小问题,记录一下以便不时之需

zjnxzy · March 15, 2013 · 1708 hits

在使用 rails 中的 Ajax 时,如果想要替换页面的数值时,如下代码所示: $("#sell_money").html("¥ <%=j @sell_money %>")其中@sell_money是后台查出的销售金额,是一个浮点型的数值,#sell_money 表示的是页面上的一个 标签。 这样会出现以下错误: undefined method gsub' for 。。。。 具体改正如下: 将$("#sell_money").html("¥ <%=j @sell_money %>") 替换成 $("#sell_money").html("¥ <%=j @sell_money.to_s %>") `

No Reply at the moment.
You need to Sign in before reply, if you don't have an account, please Sign up first.