我想to_dollar
在模型中使用如下方法:
module JobsHelper
def to_dollar(amount)
if amount < 0
number_to_currency(amount.abs, :precision => 0, :format => "-%u%n")
else
number_to_currency(amount, :precision => 0)
end
end
end
class Job < ActiveRecord::Base
include JobsHelper
def details
return "Only " + to_dollar(part_amount_received) +
" out of " + to_dollar(price) + " received."
end
end
不幸的是,该number_to_currency
方法在这里无法识别:
#<作业:0x311eb00>的未定义方法`number_to_currency'
有什么想法使它起作用吗?