金额总额后应自动加入

问题描述:

在我的应用程序中,我有诸如tax_1_amount,tax_2_amount,tax_3_amount,invoice_amount和total_invoice_amount等字段。在计算总发票金额时,amount_in_words字段应自动更新总字数。总金额计算如下:金额总额后应自动加入

@total_tax_amount = @invoice.tax_1_amount + @invoice.tax_2_amount + @invoice.tax_3_amount 
@total_amount = @total_tax_amount + @invoice.invoice_amount 

任何人都可以告诉我,如果有任何发电机或任何宝石。或者我为此写了什么代码。

+0

你应该接受解决你的问题或至少帮助的答案。 – 2012-08-09 05:39:49

+0

我不明白我必须接受 – 2012-08-09 06:39:17

+0

感谢您的建议。我认为第二个链接对我有用。 – 2012-08-09 05:44:32

+0

我安装了货币单词宝石,然后做了捆绑安装,但是当我在控制台上试过这个宝石时,它显示了这个错误:main:Object的未定义方法'number_to_currency_in_words'。 – 2012-08-09 06:33:13

+0

试一试视图。 – 2012-08-09 10:44:03

如果想在任何地方使用你需要

include ActionView::Helpers::NumberHelper 

除了一个观点。