Skip to content

Instantly share code, notes, and snippets.

@daxadax
Last active May 25, 2016 15:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daxadax/b389983e43b5f44d69cdb6cdecc4dd4a to your computer and use it in GitHub Desktop.
Save daxadax/b389983e43b5f44d69cdb6cdecc4dd4a to your computer and use it in GitHub Desktop.
override callbacks after creating models with factory girl
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