thoughtbot/factory_girl — Issue #250: Overidden attributes are not set in after_initialize callbacks.
Author: stephenprater
Created: 2011-12-08 05:30:12+00:00
State: open

The call to FactoryGirl will raise "ohnoes" - The direct call to MyThingy will not. Is that the expected behavior?

FactoryGirl.create :my_thingy, :name => "value", :value => "name"
MyThingy.create :name => "value", :value => "name"

class MyFactory < ActiveRecord::Base
after_initialize :value_name

def value_name
raise "ohnoes" if self.value == nil and self.name == nil
end
end