Skip to content

Instantly share code, notes, and snippets.

@hc5duke
Created October 8, 2012 07:00
Show Gist options
  • Save hc5duke/3851111 to your computer and use it in GitHub Desktop.
Save hc5duke/3851111 to your computer and use it in GitHub Desktop.
city and sub_cities
# sub_city.rb
class SubCity < ActiveRecord::Base
belongs_to :city
def sub_cities_names
sub_cities.map(&:name)
end
end
# city.rb
class City < ActiveRecord::Base
has_many :sub_cities
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment