我有这样的模型。覆盖属性函数rails mongoid
class Money
include Mongoid::Document
#interval is how often the compensation is paid
field :salary, :type => Integer # must be saved in cents
field :commission, :type => Integer # must be saved in cents
field :total, :type => Integer # must be saved in cents
end
总计是工资和佣金的总和。薪水和佣金都以美分保存。 但我的问题是,当它被编辑时,我需要以美元数字显示它。
例如,如果薪水分为5000000,那么当我按编辑我需要在工资文本框中看到50000。
一些其他的解决方案也受到了欢迎
感谢