Last active
May 25, 2016 15:10
-
-
Save daxadax/b389983e43b5f44d69cdb6cdecc4dd4a to your computer and use it in GitHub Desktop.
override callbacks after creating models with factory girl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FactoryGirl.define do | |
factory :my_factory do | |
cost_per_driving_hour 10 | |
cost_per_cultivation_hour 50 | |
after(:create) do |instance, evaluator| | |
instance.cost_per_driving_hour = evaluator.cost_per_driving_hour | |
instance.cost_per_cultivation_hour = evaluator.cost_per_cultivation_hour | |
instance.save | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment