Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails + FactoryGirl: What is the "evaluator" in after(:create) do |something, evaluator|?

I've been using FactoryGirl for a while now, but still don't know what evaluator means in the after create hook:

factory :products_color_with_variants do
  after(:create) do |pc, evaluator|
    pc.variants << FactoryGirl.create(:variant)
  end
end

I've only been using the first argument to the block, which is always just the object that was created. What does evaluator do and what can I use it for?

like image 529
bigpotato Avatar asked May 29 '14 20:05

bigpotato


1 Answers

This can help you. You can access transient attributes from it

like image 147
Anderson Pierok Avatar answered Nov 06 '22 06:11

Anderson Pierok