Is there a way to pre-populate a database table w/ a migration in Rails 3.x? I have a list of states, and I’d like to be able to pre-populate it whenever I’m setting up a build of the project.
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.
You could use
db/seeds.rbfor this. Good way to populate tables in a fresh app.http://ryandaigle.com/articles/2009/5/13/what-s-new-in-edge-rails-database-seeding
http://www.robbyonrails.com/articles/2009/09/05/planting-the-seeds