View raw

1 # This file should ensure the existence of records required to run the application in every environment (production, 2 # development, test). The code here should be idempotent so that it can be executed at any point in every environment. 3 # The data can then be loaded with the bin/rails db:seed command (or created alongside the database with db:setup). 4 # 5 # Example: 6 # 7 # ["Action", "Comedy", "Drama", "Horror"].each do |genre_name| 8 # MovieGenre.find_or_create_by!(name: genre_name) 9 # end 10 11 MODELS = [ Nutrient, 12 NutrientMeasurement, 13 NutrientProfile, 14 Target 15 ].freeze 16 17 def seed_file_for(model_class) 18 Rails.root.join("db", "seeds", "#{model_class.name}.rb") 19 end 20 21 MODELS.each do |model| 22 load seed_file_for(model) 23 printf "%-22s %3s\n", model.name, model.count 24 end 25