Várias sementes em trilhos 6
# lib/tasks/custom_seed.rake
# lib/tasks/custom_seed.rake
namespace :db do
namespace :seed do
Dir[File.join(Rails.root, 'db', 'seeds', '*.rb')].each do |filename|
task_name = File.basename(filename, '.rb').intern
task task_name => :environment do
load(filename)
end
end
task :all => :environment do
Dir[File.join(Rails.root, 'db', 'seeds', '*.rb')].sort.each do |filename|
load(filename)
end
end
end
end
# Then, in order to run specific seed file, you can just run
rake db:seed:seed_file_name
#To run all the seeds file with order in that db/seeds folder, run below command
rake db:seed:all
TalaatMagdy