Last active
November 10, 2020 11:28
-
-
Save skalibog/35fb7fc29956ebdfc22e06edec999644 to your computer and use it in GitHub Desktop.
custom seeds
This file contains hidden or 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[Rails.root.join('db', 'seeds', '*.rb')].each do |filename| | |
task_name = File.basename(filename, '.rb') | |
desc "Seed #{task_name}, based on the file with the same name in `db/seeds/*.rb`" | |
task task_name.to_sym => :environment do | |
load(filename) if File.exist?(filename) | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment