Created
October 8, 2012 07:00
-
-
Save hc5duke/3851111 to your computer and use it in GitHub Desktop.
city and sub_cities
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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