2014-11-06 14:46:59 +01:00
|
|
|
# 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)
|
2014-12-09 18:46:56 +01:00
|
|
|
|
2015-02-10 07:15:25 +01:00
|
|
|
DEFAULT_PASSWORD = "password"
|
|
|
|
|
|
|
|
products = [
|
|
|
|
{
|
|
|
|
name: 'Fanta',
|
|
|
|
price: 0.6,
|
|
|
|
category: 'beverages',
|
2015-02-17 15:35:15 +01:00
|
|
|
stock: 25,
|
|
|
|
avatar: File.new('public/seeds/products/fanta.jpg', 'r')
|
2015-02-10 07:15:25 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'Club Mate',
|
|
|
|
price: 1.2,
|
|
|
|
category: 'beverages',
|
2015-02-17 15:35:15 +01:00
|
|
|
stock: 25,
|
|
|
|
avatar: File.new('public/seeds/products/club_mate.jpg', 'r')
|
2015-02-10 07:15:25 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'Kinder Bueno',
|
|
|
|
price: 0.6,
|
|
|
|
category: 'food',
|
2015-02-17 15:35:15 +01:00
|
|
|
stock: 15,
|
|
|
|
avatar: File.new('public/seeds/products/bueno.jpg', 'r')
|
2015-02-10 07:15:25 +01:00
|
|
|
}
|
|
|
|
]
|
|
|
|
|
|
|
|
products.each do |attr|
|
|
|
|
Product.create name: attr[:name], price: attr[:price], category: attr[:category], stock: attr[:stock], avatar: attr[:avatar]
|
|
|
|
end
|
|
|
|
|
|
|
|
users = [
|
|
|
|
{
|
|
|
|
nickname: 'admin',
|
|
|
|
name: 'A.',
|
|
|
|
last_name: 'Admin',
|
2015-02-17 15:35:15 +01:00
|
|
|
avatar: File.new('public/seeds/users/admin.jpg', 'r'),
|
2015-02-10 07:15:25 +01:00
|
|
|
admin: true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
nickname: 'koelkast',
|
2015-02-12 14:39:58 +01:00
|
|
|
name: 'K.',
|
|
|
|
last_name: 'Koelkast',
|
2015-02-17 15:35:15 +01:00
|
|
|
avatar: File.new('public/seeds/users/admin.jpg', 'r'),
|
2015-02-10 07:15:25 +01:00
|
|
|
koelkast: true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
nickname: 'benji',
|
|
|
|
name: 'Benjamin',
|
|
|
|
last_name: 'Cousaert',
|
2015-02-17 15:35:15 +01:00
|
|
|
avatar: File.new('public/seeds/users/benji.jpg', 'r'),
|
2015-02-10 07:15:25 +01:00
|
|
|
dagschotel: Product.first
|
|
|
|
},
|
|
|
|
{
|
|
|
|
nickname: 'don',
|
|
|
|
name: 'Lorin',
|
2015-02-17 15:35:15 +01:00
|
|
|
last_name: 'Werthen',
|
|
|
|
avatar: File.new('public/seeds/users/don.jpg', 'r')
|
2015-02-10 07:15:25 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
nickname: 'silox',
|
|
|
|
name: 'Tom',
|
2015-02-17 15:35:15 +01:00
|
|
|
last_name: 'Naessens',
|
|
|
|
avatar: File.new('public/seeds/users/silox.jpg', 'r')
|
2015-02-10 07:15:25 +01:00
|
|
|
}
|
|
|
|
]
|
|
|
|
|
|
|
|
users.each do |attr|
|
|
|
|
User.create nickname: attr[:nickname], name: attr[:name], last_name: attr[:last_name], avatar: attr[:avatar], dagschotel: attr[:dagschotel], password: DEFAULT_PASSWORD, password_confirmation: DEFAULT_PASSWORD, admin: attr[:admin] || false, koelkast: attr[:koelkast] || false
|
|
|
|
end
|
2015-02-19 17:40:29 +01:00
|
|
|
|
|
|
|
50.times do |i|
|
|
|
|
User.create nickname: "TestUser#{i}", name: "Test", last_name: "User", avatar: users[0][:avatar], password: DEFAULT_PASSWORD, password_confirmation: DEFAULT_PASSWORD
|
|
|
|
end
|