我使用FactoryGirl示例has_many
关系从http://robots.thoughtbot.com/post/254496652/aint-no-calla-back-girl。具体地,示例的是:FactoryGirl has_many association
型号:
class Article < ActiveRecord::Base
has_many :comments
end
class Comment < ActiveRecord::Base
belongs_to :article
end
工厂:
factory :article do
body 'password'
factory :article_with_comment do
after_create do |article|
create(:comment, article: article)
end
end
end
factory :comment do
body 'Great article!'
end
当我运行相同的例子(与适当的模式,当然),引发错误
2.0.0p195 :001 > require "factory_girl_rails"
=> true
2.0.0p195 :002 > article = FactoryGirl.create(:article_with_comment)
ArgumentError: wrong number of arguments (3 for 1..2)
是否有一种新方法可以与FactoryGirl建立has_many
关联?