I'm a brand new developer so this might be a dumb question.
I am trying to setup a webapp which will store stats on geographic data.
- I have a model called Stat which has fields for basic statistical information (median, variance, avg, etc.).
- I have setup models for each geographic units City, Zip, Sub-Zip
What I want to do know is associate the Stat model with Cities, Zips, and Sub-Zips; that is every stat model belongs to either a city, zip, or sub-zip while a geographic unit (city,zip,sub-zip) can have multiple stats.
How do I setup the associations and migration to do this? I've looked through the Rails guides but it doesn't seem to cover a relationship where an object can belong to different models (but only one of them). Or should I set up my models differently?