Created
June 7, 2013 01:30
-
-
Save the-teacher/5726487 to your computer and use it in GitHub Desktop.
multiple seeds This will allow you to do rake db:seed:x where “x” is a file in the db/seeds directory:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :db do | |
namespace :seed do | |
Dir[File.join(Rails.root, 'db', 'seeds', '*.rb')].each do |seed_file| | |
task_name = File.basename(seed_file, '.rb').intern | |
desc "Load the seed data from db/seeds/#{task_name}.rb" | |
task task_name => :environment do | |
load(seed_file) if File.exist?(seed_file) | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment