我有一个广告工厂,但如何将其分配给 user.ads 属性?我试过了
@ad = user.ads.build(:ad)
但这对我不起作用
FactoryGirl.define do
factory :user do
name "My"
email "my@example.com"
end
factory :ad do
title "Ola"
description "Hello"
user
end
end
let(:user) { FactoryGirl.create(:user) }
#so i don't type it like this:
@ad = user.ads.build(title: "Lorem ipsum",description: "Lorem ipsum")
subject { @ad }