How to build a parent with child factory in one step in order to pass validation
问题 Projects must have at least one task created at the same time to ensure the validation passes. This is the snippet I use to validate this: class Project < ActiveRecord::Base validates :tasks, :length => { :minimum => 1 } ... end The challenge I'm having is create the right factory to build a project with task upfront using FactoryGirl. I'm using: FactoryGirl.define do factory :task do name "Get this test passing" project end factory :project do title "Complete the application" factory