我运行了代码@transaction = Transaction.new然后我给了它一些值:
<Transaction id: nil,debit_uri: "d8hmFJ89CIQUZMBoiPMnvWkQJW/bank_...",credit_uri: "d8hmciqLOg9bCIQUZMBoiPMnvWkQJW/cards...",seller_id: 2,buyer_id: 6,product_id: 31,price: #<BigDecimal:b4a6115c,'0.45E2',9(36)>,ship_price: #<BigDecimal:b4a61094,'0.123E3',ship_method: "fedex",created_at: nil,updated_at: nil>
但是当我做@ transaction.save时! bang(!)或不是我收到错误:
NoMethodError: undefined method `clear' for nil:NilClass from /home/alain/.rvm/gems/ruby-1.9.3-head/gems/activemodel-3.2.13/lib/active_model/validations.rb:194:in `valid?'
所以我不知道在哪里寻找错误是我的模型几乎没有什么,没有一个叫做clear的方法.
class Transaction < ActiveRecord::Base attr_accessible :buyer_id,:credit_uri,:debit_uri,:price,:product_id,:seller_id,:ship_method,:ship_price require 'balanced' attr_reader :errors end