How would migrations be involved? Would you load them into the mysql db directly or have a ruby routine doing this.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
To get the raw data I’d simply search on Google, you’ll find lots of databases of zip codes, some of them are not free though.
Then I’d look at the data to get a clue on what columns I should include in the table, and build an appropriate migration and model.
Then I’d write an external ruby script which reads the data from whatever format the zip code database is in and writes it directly into the app’s database. You could also do that as part of your Rails application, but I usually don’t consider it necessary when dealing with external data only.
It’s important, however, that the zip code table is not referenced by ID in some other table, since that makes it really complicated if you want to update it later (zip codes change). So I’d still store the zip code itself in, say, the user table, or wherever.