I’ve got a database structure which has this sort of thing.
A Resort is in a particular country.
Presently the country is stored in a field in the Resort model,
Resort.country (a string).
I want to do this properly and have done the following
- added a new field to resort called country_id.
- creating a countries table Country with just name:string
- Load up a list of all unique countries into my Country model
- Resort belongs_to country
- Country has_many resorts
- Somehow I now need to add the relevant country_ids to each Resort by
searching Resort.country and matching against Country.name
Anyone help me - is this on the right lines? and how do I do step 5 (got
the rest I think).