Is there a way to get the Faker gem to generate 'correlated' city and country code values?
For example,
- Vancouver, CA
- Minneapolis, MN
I'm doing this:
FactoryGirl.define do
factory :location do
...
city {Faker::Address.city}
country_code {['US', 'CA'].sample}
...
end
end
But there is no guarantee that the city
will actual reside in country_code
.
I'd settle for something like:
postal_code {Faker::Address.postcode(['US', 'CA'].sample) }
Which I could then geocode to get the other values.