On 1/12/07, Kevin Burk <[EMAIL PROTECTED]> wrote:
One option would be to use raw SQL statements in your migration, like this:
Also, if you have a fair amount of data and can massage it into YAML, you could try something like the ar_fixtures plugin. I use that plugin on pretty much every project I've done. It's good stuff. At the very least you can peruse its source for a few ideas on loading data from files. http://nubyonrails.com/articles/2005/12/27/dump-or-slurp-yaml-reference-data Here's an excerpt of some relevant code from the plugin that loads a YAML file and creates a new ActiveRecord object from it. records = YAML::load( File.open( File.expand_path(path, RAILS_ROOT) ) ) records.each do |record| record_copy = self.new(record.attributes) # ... end Of course, the plugin extends ActiveRecord::Base, so 'self' is referring to an instance of an ActiveRecord object. To use this in a migration you'd want to familiarize yourself with the YAML module and grab values out of that record object. Of course, ymmv. If you only have a little bit of data, this is probably overkill. :) -- Nick Zadrozny • http://missionsbridge.org/people/nick _______________________________________________ Sdruby mailing list [email protected] http://lists.sdruby.com/mailman/listinfo/sdruby
