compatibility update for rails 3.1

cherry-picked commit 65b8bae892cc18129753 from iortega/db-populate, replacing deprecated
RAILS_ROOT in favor of Rails.root
This commit is contained in:
Kevin Triplett 2011-07-23 14:38:40 -05:00
parent f1190e06c8
commit 127334ac1c

View File

@ -2,16 +2,16 @@ namespace :db do
desc "Loads initial database models for the current environment."
task :populate => :environment do
require 'create_or_update'
Dir[File.join(RAILS_ROOT, 'db', 'populate', '*.rb')].sort.each do |fixture|
require File.join(File.dirname(__FILE__), '/../lib', 'create_or_update')
Dir[File.join(Rails.root, 'db', 'populate', '*.rb')].sort.each do |fixture|
load fixture
puts "Loaded #{fixture}"
end
(Dir[File.join(RAILS_ROOT, 'db', 'populate', RAILS_ENV, '*.rb')] + Dir[File.join(RAILS_ROOT, 'db', 'populate', 'shared', '*.rb')]).sort{|x,y| File.basename(x) <=> File.basename(y)}.each do |fixture|
(Dir[File.join(Rails.root, 'db', 'populate', Rails.env, '*.rb')] + Dir[File.join(Rails.root, 'db', 'populate', 'shared', '*.rb')]).sort{|x,y| File.basename(x) <=> File.basename(y)}.each do |fixture|
load fixture
puts "Loaded #{fixture}"
end
Dir[File.join(RAILS_ROOT, 'db', 'populate', 'after', '*.rb')].sort.each do |fixture|
Dir[File.join(Rails.root, 'db', 'populate', 'after', '*.rb')].sort.each do |fixture|
load fixture
puts "Loaded #{fixture}"
end