ruby on rails - Factory girl conflict between field names with association -
for legacy reasons, have model in rails 2 fields: city
, city_id
.
city
string city name. city_id
reference city
object.
how should declare factory factory_girl?
i populate both city_id , city this:
factory :address street "street x" city #uses city factory city "mycity" #uses legacy city end
but not possible. how differentiate between these 2 city fields?
as per the docs, can use implicit association when you're following normal conventions. case need use explicit call association
method.
in example below, replace :replace_this
whatever belongs_to
association in model called:
factory :address street "street x" association :replace_this, factory: :city #uses city factory city "mycity" #uses legacy city end
Comments
Post a Comment