Skip to content

Instantly share code, notes, and snippets.

@pjbelo
Created July 20, 2018 16:58
Show Gist options
  • Save pjbelo/a6fb7155725c9bb64cd0b86323351e47 to your computer and use it in GitHub Desktop.
Save pjbelo/a6fb7155725c9bb64cd0b86323351e47 to your computer and use it in GitHub Desktop.
split and organize seeds.rb [rails]
# store all seeds inside the folder db/seeds
# files are sorted alphabetically before loading them, so we can make sure the files are processed in order
# choose the filenames wisely, e.g. something like 0100_operators.rb, 0200_companies.rb, 0300_products.rb ...)
#
Dir[File.join(Rails.root, 'db', 'seeds', '*.rb')].sort.each { |seed| load seed }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment