Undefined method after_create with FactoryGirl
问题 I'm trying to defined a has_many relationship in FactoryGirl using the after_create callback, like so in /spec/factories/emails.rb: FactoryGirl.define do factory :email do after_create do |email| email.attachments << FactoryGirl.build(:attachment) end end end The attachment is defined in a seperate factory /spec/factories/attachment.rb: FactoryGirl.define do factory :attachment do # Attach the file to paperclip file { fixture_file_upload(Rails.root.join('spec', 'support', 'myimage.png'),