Factory Girl: Jak skonfigurować skojarzenie has_many / through

Walczyłem z konfiguracjąhas_many/through związek z Factory Girl.

Mam następujące modele:

class Job < ActiveRecord::Base
  has_many :job_details, :dependent => :destroy
  has_many :details, :through => :job_details
end

class Detail < ActiveRecord::Base
  has_many :job_details, :dependent => :destroy
  has_many :jobs, :through => :job_details
end

class JobDetail < ActiveRecord::Base
  attr_accessible :job_id, :detail_id
  belongs_to :job
  belongs_to :detail
end

Moja fabryka:

factory :job do
  association     :tenant
  title           { Faker::Company.catch_phrase }
  company         { Faker::Company.name }
  company_url     { Faker::Internet.domain_name }
  purchaser_email { Faker::Internet.email }
  description     { Faker::Lorem.paragraphs(3) }
  how_to_apply    { Faker::Lorem.sentence }
  location        "New York, NY"
end

factory :detail do
  association :detail_type <--another Factory not show here
  description "Full Time"
end

factory :job_detail do
  association :job
  association :detail
end

Chcę, aby moja praca została utworzona z ustawieniem domyślnymDetail „Pełny czas”.

Próbowałem to śledzić, ale nie miałem szczęścia:FactoryGirl ma wiele

Nie jestem pewien, jakafter_create powinien być użyty do dołączenia szczegółu przez JobDetail.

questionAnswers(4)

yourAnswerToTheQuestion