如果我给
p @work_orders.where(wo_number: 34305)
在我的控制器中,终端中的o / p将是
#<ActiveRecord::Relation [#<WorkOrder id: 9168, shop_number: 3, ticket_number: 0, wo_number: 34305, date: "2014-04-02 02:24:57", time: "2000-01-01 15:54:57", customerPO: "", warranty_code: "1", market_source: "", sub_total: #<BigDecimal:bba2164,'0.72456E3',18(18)>, discount_type: "dollar", discount_amount: #<BigDecimal:bba20b0,'0.0',9(18)>, tax: #<BigDecimal:bba2038,'0.39E0',9(18)>, tax_exemptID: "", order_type: "regular", created_at: "2014-07-17 06:25:26", updated_at: "2014-07-17 06:25:26">]>
我正在尝试检索小计的值.. 到目前为止,我已经尝试过..
p @work_orders.where(wo_number: 34305).first.sub_total
导致错误
undefined method `sub_total' for nil:NilClass