0

コンソールで私は:

board = FactoryGirl.build(:board_with_source)

board.sources
=> [#<Board id: 6, name: "Free Ruby Books", description: "Ruby Books - Free and Paid ones", created_at: "2013-06-21 12:21:34", updated_at: "2013-06-21 12:21:34", user_id: nil>]

board.sources.count
=> 0 

0 と表示されるのはなぜですか?

ファクトリーガールのセットアップ:

# Read about factories at https://github.com/thoughtbot/factory_girl

FactoryGirl.define do
  factory :board do
    name "Ruby Books"
    description "Ruby Books - Free and Paid ones"
  end

  factory :board_with_source, parent: :board do
    after :build do |board|
      board.sources << FactoryGirl.create(:board, name: "Free Ruby Books")
    end
  end
end
4

1 に答える 1