Hi, I would like to fill up a development database with some data (YAML files). YAML is ready, but I don't have any clue to load them into AR objects, and persist them to the database (files are utf-8). Any help? Jean-Etienne
on 2005-11-26 11:52
on 2005-11-26 13:25
Jean-Etienne: I may have missed your point, but in case I didn't and this saves you some time. Open terminal and type something like this: mysql - u root -p<<password goes here>> <<database_name>> goes here < <<path_tp_yaml_file_goes_here>> bruce
on 2005-11-26 15:33
On 26-nov-2005, at 13:24, Bruce Balmer wrote: > Jean-Etienne: > > I may have missed your point, but in case I didn't and this saves > you some time. > > Open terminal and type something like this: > > mysql - u root -p<<password goes here>> <<database_name>> goes > here < <<path_tp_yaml_file_goes_here>> Since when MySQL directly supports YAML dumps, may I ask? -- Julian 'Julik' Tarkhanov me at julik.nl
on 2005-11-26 16:26
If you want to load your test fixtures to the development database, just run "rake load_fixtures". If you want to have separate fixtures for dev and test, put your dev fixtures in another directory (say, "db/fixtures") and copy this to lib/tasks/fixtures.rake or your Rakefile: desc "Load fixtures into the current environment's database" task :load_dev_fixtures => :environment do require 'active_record/fixtures' ActiveRecord::Base.establish_connection(RAILS_ENV.to_sym) Dir.glob(File.join(RAILS_ROOT, 'db', 'fixtures', '*.yml')).each do |fixture_file| Fixtures.create_fixtures('db/fixtures', File.basename (fixture_file, '.*')) end end Which is just a copy of the original load_fixtures tasks from rails/ railties/lib/tasks/database.rake with the paths changed.