我有一个城市工厂我想根据 factory_name 添加关联但我不知道如何在定义中引用名称...
factory :place do
loc_geographic "-82.283204,29.320888"
city "Some City"
country 'USA'
after(:build) do |place, eval|
place.images << FactoryGirl.build("place_image_#{__FACTORY_NAME__}".to_sym)
end
factory :ny do
city "New York"
end
end
factory :place_image_ny, class: 'Place::Picture' do
attachment {File.open(File.join(Rails.root, "/spec/fixtures/attachment/place_ny.jpg"))}
end