I want to setup contry code for my Rails app so I searched by google there are some Gem but I just want to make Tables & Model.
I used data from here
Make migratiton file
1 2 3 4 5 6 |
$ rails g model country name:string alpha_2:string alpha_3:string invoke active_record create db/migrate/20130206044924_create_countries.rb create app/models/country.rb invoke rspec create spec/models/country_spec.rb |
Add SQL from here
1 2 3 4 5 6 7 8 9 |
$ vi db/migrate/20130206044924_create_countries.rb #add data from http://stefangabos.ro/other-projects/list-of-world-countries-with-national-flags/ execute " INSERT INTO `countries` (`name`, `alpha_2`, `alpha_3`) VALUES ('Afghanistan', 'af', 'afg'), ('Aland Islands', 'ax', 'ala'), ('Albania', 'al', 'alb'), more... ('Zimbabwe', 'zw', 'zwe')" |
and then
1 |
$ rake db:migrate |
Done.