last day (14 days later) » 

4:04 PM
0
A: NameError: undefined local variable or method `post' for #<FactoryGirl.Rspec

BroiSatseYou didn't pass object to after_create block. You also didn;t specify the number of comments to be created. Change your trait to: trait :with_comments do after(:create) do |post| create_list(:comment, <number_of_comments>, post: post) end end

 
thank you for the answer, but shell render another error. NoMethodError: undefined method `times' for #<Hash:0x000000083c1da8>
 
That's because you haven't specify number of comments to be created.
 
sorry, but I don't understand how to specify comment number?
 
It is explained in my answer?
 
because that's how 'create_list(:comment, 5, post: post)' is don't working
 
4:04 PM
what error do you get?
 
exactly the same error
NoMethodError: undefined method `times' for
 
Hi, I'll be back in 20-30 minutes if that's ok?
 
ok, I'm still going to solve this problem
tahnk you
 
4:23 PM
Hi
Just a question - how did you run the factory?
Through the console or with rspec?
Factories are registered when FactoryGirl gem is loaded
Which meas you need to restart the application for any changes in a factory to take place
 

last day (14 days later) »