【发布时间】:2012-02-02 02:12:09
【问题描述】:
在报价控制器中保存新报价时,我们的 rails 3.1.0 应用程序出现了一个奇怪的错误。报价属于 rfq 并且 rfq 是 18 被传递到报价控制器。错误是:
Validation failed: Quoted total is not a number
显示的参数有:
{"utf8"=>"✓",
"authenticity_token"=>"p9waUq7wNk6djm9uRtDOA0eHLzzlJuSCWrTsSEBvcck=",
"quote"=>{"test_item_ids"=>["1",
"2"],
"_destroy"=>"false",
"quoted_total"=>"290"},
"commit"=>"Save",
"rfq_id"=>"18"}
正如它所显示的,quoted_total 是 290。但不知何故,它没有被识别为一个数字。
这是引号控制器中的创建代码:
@quote = @rfq.quotes.new(params[:quote], :as => :roles_new)
@quote.input_by_id = session[:user_id]
@quote.test_items = TestItem.find_all_by_id(params[:quote][:test_item_ids])
if @quote.save!
redirect_to URI.escape("/view_handler?index=0&msg=quote saved!")
else
flash.now[:error] = "Not saved!"
render 'new'
end
错误是由@quote.save 引起的。报价控制器的 rspec 代码具有相同的错误。是什么导致了错误?非常感谢。
【问题讨论】:
标签: ruby-on-rails ruby-on-rails-3.1 rspec2