Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

loading fixtures to development database (See related posts)

Fixed the previous example so it would load environment first:

desc "Load fixtures data into the development database"
task :load_fixtures_to_development => :environment do
  ActiveRecord::Base.establish_connection(:development)
  require 'active_record/fixtures'
  Fixtures.create_fixtures("test/fixtures", ActiveRecord::Base.configurations[:fixtures_load_order])
  puts "Loaded these fixtures: " + ActiveRecord::Base.configurations[:fixtures_load_order].collect { |f| f.to_s }.join(', ')
end


This requires a fixture list in database.yml (or you can specify in environment.rb if you wish:

:fixtures_load_order:
  - :fixture_1
  - :fixture_2
  - :fixture_3
  - :fixture_4
  - :fixture_5

You need to create an account or log in to post comments to this site.


Click here to browse all 4852 code snippets

Related Posts