工厂女孩创造错误

时间:2013-04-13 19:45:15

标签: ruby-on-rails rspec factory-bot

company_factory.rb

Factory.define :company, :class => Company do |c|
      c.company_name 'companyname'
      c.address 'companyadress'
      c.phone '012323232'
      c.company_prize_ratio 10
      c.partner_prize_ratio 10
      c.bank_name 'bankname'
      c.iban 'iban'
      c.sequence(:company_password ) {|n| "company_password_#{n}"}
    end

partner_factory.rb

Factory.define :partner, :class => Partner do |i|
  i.association :company, :factory => :company
  i.email 'partner@mail.com'
  i.password 'partnerpassword'
  i.partner_name 'partnername'
  i.partner_type :nil
end

这些是我的工厂文件。当我在pry中运行@company = Factory(:company)此命令时,它会创建公司工厂,但是当我运行@partner = Factory(:partner)时遇到此错误

ActionView::Template::Error: undefined method `user_type' for #<Partner:0x007fa56d339860>

但伙伴模型中没有user_type属性。你知道我为什么会收到这个错误吗?

0 个答案:

没有答案