Skip to content

Instantly share code, notes, and snippets.

@skalibog
Last active November 10, 2020 11:28
Show Gist options
  • Save skalibog/35fb7fc29956ebdfc22e06edec999644 to your computer and use it in GitHub Desktop.
Save skalibog/35fb7fc29956ebdfc22e06edec999644 to your computer and use it in GitHub Desktop.
custom seeds
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