开发者

How do I seed data into new columns in an existing Rails model?

开发者 https://www.devze.com 2023-01-08 22:40 出处:网络
I have a rails model called County that has 5 columns of data for different population attributes for that county. There is a record in the counties table for each county in the US. I now need to add

I have a rails model called County that has 5 columns of data for different population attributes for that county. There is a record in the counties table for each county in the US. I now need to add additional county level data to meet a new need. The counties table will get an additional 10 or so rows for numeric population data (breakdown by race and ethnicity). I currently have the data in a .csv file, ready to go.

How do I seed the new data into the existing model such that I fill in the county specific information for each county in the database? Can this be done with ra开发者_JS百科ke db:seed?


To start with, you can use FasterCSV to parse your input file. From there if you have a specific question please ask.

0

精彩评论

暂无评论...
验证码 换一张
取 消