This may be another basic question, but I can't find a coherent answer anywhere in either Rails or SQL books.

I need to load a chunk of data into my SQL database. I'd like to do this using a data migration in Rails. Until now, I've created the migration, and edited the migration file with the full code:

User.create(:name => 'Kevin Burk',
          :city => 'San Diego')

User.create(:name => 'Someone Else',
          :city => 'San Diego')

and so forth. This is rather tedious, especially when I have a great deal of data I want to incorporate. However, it does allow me to add and drop all of the development data as needed, which is what I want.

In AWR2, in the migrations chapter, they talk about loading data from fixtures, using a YAML file. The form and syntax of the YAML file is never discussed, and I can't get a straight answer from the author telling me how to structure the YAML file. He's talking about row labels, which I don't understand-and they don't seem to relate to the "id" field for the row that is automatically generated when I run the User.create() function in the migration file.

I have no SQL experience, and no desire to go under the hood with SQL. However, there must be a way that I can create an external data file (as YAML, text, or whatever) that involves less typing, easier syntax, and keeps my data_migration.rb files reasonably small.

Using the User.create() approach in the rails migration is already a vast improvement over the raw SQL INSERT code. I'd just like to know if there's an easier way-and if there is, to have it described in great detail because I lack the programming background to make some very fundamental connections about how certain things are done.

Thanks for your help!

Kevin Burk
--
***************************************
BURK DESIGN GROUP
http://www.BurkDesignGroup.com
mailto:[EMAIL PROTECTED]
6161 El Cajon Blvd #306
San Diego, CA 92115
PHONE (619) 583-2311
FAX (619) 583-5801
***************************************
_______________________________________________
Sdruby mailing list
[email protected]
http://lists.sdruby.com/mailman/listinfo/sdruby

Reply via email to