.count pokazuje zly wynik

W konsoli wpisuje

[code]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[/code]
Dlaczego 0, a nie 1 ??

FactoryGirl:

[code=ruby]# 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[/code]

chyba nie zapisałeś tego jeszcze w bazie i dlatego zwraca Ci 0.

Robisz build a nie create

build == new
create == create

ok, dzięki