Sha256: 4c7ddf80cb1144718c845eeb3bd684e287f648189ac2b7259015bc2748df61a5

Contents?: true

Size: 828 Bytes

Versions: 1

Compression:

Stored size: 828 Bytes

Contents

namespace :db do
  desc "Load seed files (from db/seeds) into the current environment's database." 
  task :active_seed => :environment do
    require "active_seed/seed_csv"
    set = ENV["set"] 
    set = ::Rails.env unless !set.nil?
    set_file = File.join(::Rails.root.to_s, "db", "active_seed", set + ".yml")
    if !File.exists?(set_file)
    	puts "Set file doesn't exist: " << set_file
	    return
    end
    puts "Seeding from set '" + set + "'"
    fixture_list = YAML::load_file(set_file)
    fixture_list.each do |model, sf| 
	    seed_file = File.join(::Rails.root.to_s, "db", "active_seed", "data", sf + ".csv")
    	if !File.exists?(seed_file)
		    puts "Seed file doesn't exist: " << seed_file
    	else
		    puts "Seeding '" + seed_file + "'..." 
		    seed_csv(model, seed_file) 
	    end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
active_seed-1.0.3 lib/tasks/active_seed_tasks.rake