forked from joho/geonames-rails
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding generators for the models and migration
- Loading branch information
Showing
7 changed files
with
41 additions
and
1 deletion.
There are no files selected for viewing
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
7 changes: 7 additions & 0 deletions
7
lib/generators/geonames_migration/geonames_migration_generator.rb
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class GeonamesMigrationGenerator < Rails::Generator::Base | ||
def manifest | ||
record do |m| | ||
m.migration_template 'geonames_tables.rb',"db/migrate", :migration_file_name => "create_geonames_tables" | ||
end | ||
end | ||
end |
14 changes: 14 additions & 0 deletions
14
lib/generators/geonames_migration/templates/geonames_tables.rb
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
class CreateGeonamesTables < ActiveRecord::Migration | ||
def self.up | ||
# blah | ||
|
||
# create countries | ||
# create regions | ||
# create cities | ||
end | ||
|
||
def self.down | ||
# drop all the tables | ||
# %w(countries regions cities) { |t| drop_table t } | ||
end | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class GeonamesMigrationGenerator < Rails::Generator::Base | ||
def manifest | ||
record do |m| | ||
# Do something | ||
end | ||
end | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
class City < ActiveRecord::Base | ||
belongs_to :region | ||
has_one :country, :through => :region | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
class Country < ActiveRecord::Base | ||
has_many :regions | ||
has_many :cities, :through => :regions | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
class Region | ||
belongs_to :country | ||
has_many :cities | ||
end |