1

In my application I have fields like tax_1_amount, tax_2_amount, tax_3_amount, invoice_amount and total_invoice_amount. When the total invoice amount is calculated then the amount_in_words field should be automatically updated by the total amount in words. Total amount is calculated as follows:

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

Can anyone tell me if there is any generator or any gem for that. Or what code shall I write for that.

4

2 回答 2

1

你需要

include ActionView::Helpers::NumberHelper

如果尝试使用视图以外的任何地方。

于 2014-09-15T03:52:40.393 回答
0

我不确定我是否理解,但请查看此链接

http://api.rubyonrails.org/classes/ActionView/Helpers/NumberHelper.html#method-i-number_to_human

或者

https://github.com/bcarrere/currency-in-words

于 2012-08-09T05:26:38.810 回答