# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
#   cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
#   Mayor.create(name: 'Emanuel', city: cities.first)

# import crops from CSV

require 'csv'

CSV.foreach(Rails.root.join('db', 'seeds', 'crops.csv')) do |row|
  system_name,scientific_name,en_wikipedia_url = row
  @crop = Crop.create(:system_name => system_name, :en_wikipedia_url => en_wikipedia_url)
  @crop.scientific_names.create(:scientific_name => scientific_name)
end

# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
#   cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
#   Mayor.create(name: 'Emanuel', city: cities.first)

# import crops from CSV

require 'csv'

puts "Loading crops..."
CSV.foreach(Rails.root.join('db', 'seeds', 'crops.csv')) do |row|
  system_name,scientific_name,en_wikipedia_url = row
  @crop = Crop.create(:system_name => system_name, :en_wikipedia_url => en_wikipedia_url)
  @crop.scientific_names.create(:scientific_name => scientific_name)
end
puts "Finished loading crops"

puts "Loading test users..."
if Rails.env.development? or Rails.env.test?
  (1..3).each do |i|
    @user = User.create(:username => "test#{i}", :email => "test#{i}@example.com", :password => "password#{i}")
    @user.confirm!
    @user.save!
  end
end
puts "Finished loading test users"

Create some test users in dev and test environments.
Create some test users in dev and test environments.

They're called test1, test2, test3 and have passwords password1 etc.
Run `rake db:seed` or `rake db:setup` to get them.
