Over a million developers have joined DZone.

Loading Fixtures To Development Database

DZone's Guide to

Loading Fixtures To Development Database

· ·
Free Resource
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
  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(', ')

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

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

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}