模型中表report_merge_holders的未知主键

时间:2015-12-28 11:21:07

标签: ruby-on-rails unit-testing ruby-on-rails-4

 require 'test_helper'

 class GenerateReportControllerTest < ActionController::TestCase

 setup do
  @client = clients(:one)    
  @results = report_merge_holders(:one)
 end

In `fixtures/report_merge_holders.yml`:
   one:
    id: 1
    client_id: "1"
    FOLIO_NO: "12323"

In `fixtures/clients.yml`:
   one:
    id: 1
    isin_number: "SDS232"
    code: "232DD"
    name: "KJHSFDKJ"

我是#34;单元测试&#34;。我想设置&#34; client_id&#34;我得到的错误如"ActiveRecord::UnknownPrimaryKey: Unknown primary key for table report_merge_holders in model ReportMergeHolder"。请帮帮我。

1 个答案:

答案 0 :(得分:0)

如果正确创建了表,则不必将主ID指定为:id。查看schema.rb文件,检查report_merge_holders函数中的id: false是否create_table。移除id: false如果它存在且事情应该有效。