Skip to content

Commit

Permalink
Introduced the FIXTURE_PATH environment variable for the db:seed rake…
Browse files Browse the repository at this point in the history
… task so you can store fixtures in a place besides db
  • Loading branch information
zdennis committed Jul 16, 2008
1 parent 93e5406 commit 4d391aa
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions tasks/seed_fu_tasks.rake
@@ -1,12 +1,13 @@
namespace :db do
desc "Loads seed data from db/fixtures for the current environment."
task :seed => :environment do
Dir[File.join(RAILS_ROOT, 'db', 'fixtures', '*.rb')].sort.each { |fixture|
fixture_path = ENV["FIXTURE_PATH"] ? ENV["FIXTURE_PATH"] : "db/fixtures"
Dir[File.join(RAILS_ROOT, fixture_path, '*.rb')].sort.each { |fixture|
puts "\n== Seeding from #{File.split(fixture).last} " + ("=" * (60 - (17 + File.split(fixture).last.length)))
load fixture
puts "=" * 60 + "\n"
}
Dir[File.join(RAILS_ROOT, 'db', 'fixtures', RAILS_ENV, '*.rb')].sort.each { |fixture|
Dir[File.join(RAILS_ROOT, fixture_path, RAILS_ENV, '*.rb')].sort.each { |fixture|
puts "\n== [#{RAILS_ENV}] Seeding from #{File.split(fixture).last} " + ("=" * (60 - (20 + File.split(fixture).last.length + RAILS_ENV.length)))
load fixture
puts "=" * 60 + "\n"
Expand Down

0 comments on commit 4d391aa

Please sign in to comment.