2011-01-22 159 views
0

嘿,需要帮助来设置Rails3中的计算。使用Rails3进行计算

首先,我应该在我的模型中编写逻辑吧? (交易)

然后,我们假设我想将小计和总额插入到Db中。你推荐什么方法? 以下是我将作为出发点。

在我的模型:小计=量

def subtotal 
    @subtotal = :amount #table column 
end 

在我的模型:总=大部+税

def total 
@total = :subtotal + :tax #again referring to table column 
end 

回答