Skip to content

Instantly share code, notes, and snippets.

@maxschulze
Created December 9, 2010 15:12
Show Gist options
  • Select an option

  • Save maxschulze/734805 to your computer and use it in GitHub Desktop.

Select an option

Save maxschulze/734805 to your computer and use it in GitHub Desktop.
Proposal for Radio Locations / Stations
##
# This way a radio location/station can have many cities, countries and continents, e.g.
# for a global online radio channel.
#
# A Radio Location can have just a city or country etc.
#
class RadioStation
belongs_to :radio_location
end
class RadioLocation
has_and_belongs_to_many :cities
has_and_belongs_to_many :states
has_and_belongs_to_many :countries
has_and_belongs_to_many :continents
has_many :radio_stations
# attributes: street, zipcode, latitude, longitude
end
class City
belongs_to :state
has_and_belongs_to_many :radio_locations
# attributes: name
# maybe semantic data here
end
class State
belongs_to :country
has_many :cities
has_and_belongs_to_many :radio_locations
# attributes: name
# maybe semantic data here
end
class Country
belongs_to :continent
has_many :states
has_and_belongs_to_many :radio_locations
# attributes: name, code
# maybe semantic data here
end
class Continent
has_many :countries
has_and_belongs_to_many :radio_locations
# attributes: name
# maybe semantic data here
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment