2012-08-09 142 views
1

在我的應用程序中,我有諸如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
+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

0

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

include ActionView::Helpers::NumberHelper 

除了一個觀點。