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)
|
2015-03-19 16:22:55 +01:00
|
|
|
DEFAULT_PASSWORD = "password"
|
2014-12-09 18:46:56 +01:00
|
|
|
|
2015-03-19 16:22:55 +01:00
|
|
|
products = [
|
|
|
|
{
|
|
|
|
name: 'Fanta',
|
|
|
|
price: 0.6,
|
|
|
|
category: 'beverages',
|
|
|
|
stock: 25,
|
|
|
|
avatar: File.new('public/seeds/products/fanta.jpg', 'r')
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'Club Mate',
|
|
|
|
price: 1.2,
|
|
|
|
category: 'beverages',
|
|
|
|
stock: 25,
|
|
|
|
avatar: File.new('public/seeds/products/club_mate.jpg', 'r')
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'Kinder Bueno',
|
|
|
|
price: 0.6,
|
|
|
|
category: 'food',
|
|
|
|
stock: 15,
|
|
|
|
avatar: File.new('public/seeds/products/bueno.jpg', 'r')
|
|
|
|
}
|
|
|
|
]
|
|
|
|
|
|
|
|
products.each do |attr|
|
|
|
|
Product.create name: attr[:name], price: attr[:price], category: attr[:category], stock: attr[:stock], avatar: attr[:avatar]
|
|
|
|
end
|
|
|
|
|
|
|
|
users = [
|
|
|
|
{
|
2015-03-20 04:20:39 +01:00
|
|
|
uid: 'admin',
|
2015-03-19 16:22:55 +01:00
|
|
|
avatar: File.new('public/seeds/users/admin.jpg', 'r'),
|
|
|
|
admin: true
|
|
|
|
},
|
|
|
|
{
|
2015-03-20 04:20:39 +01:00
|
|
|
uid: 'koelkast',
|
2015-03-19 16:22:55 +01:00
|
|
|
avatar: File.new('public/seeds/users/admin.jpg', 'r'),
|
|
|
|
koelkast: true
|
|
|
|
},
|
|
|
|
{
|
2015-03-20 04:20:39 +01:00
|
|
|
uid: 'benji',
|
2015-03-19 16:22:55 +01:00
|
|
|
avatar: File.new('public/seeds/users/benji.jpg', 'r'),
|
2015-03-20 04:20:39 +01:00
|
|
|
dagschotel: Product.first,
|
|
|
|
provider: 'zeuswpi'
|
2015-03-19 16:22:55 +01:00
|
|
|
},
|
|
|
|
{
|
2015-03-20 04:20:39 +01:00
|
|
|
uid: 'don',
|
2015-03-19 16:22:55 +01:00
|
|
|
avatar: File.new('public/seeds/users/don.jpg', 'r')
|
|
|
|
},
|
|
|
|
{
|
2015-03-20 04:20:39 +01:00
|
|
|
uid: 'silox',
|
2015-03-19 16:22:55 +01:00
|
|
|
avatar: File.new('public/seeds/users/silox.jpg', 'r')
|
|
|
|
}
|
|
|
|
]
|
|
|
|
|
|
|
|
users.each do |attr|
|
2015-03-19 17:38:59 +01:00
|
|
|
User.create(
|
2015-03-20 04:20:39 +01:00
|
|
|
uid: attr[:uid],
|
|
|
|
provider: attr[:provider],
|
2015-03-19 17:38:59 +01:00
|
|
|
avatar: attr[:avatar],
|
|
|
|
dagschotel: attr[:dagschotel],
|
|
|
|
password: DEFAULT_PASSWORD,
|
|
|
|
admin: attr[:admin] || false,
|
|
|
|
koelkast: attr[:koelkast] || false
|
|
|
|
)
|
2015-03-19 16:22:55 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
50.times do |i|
|
2015-03-19 17:38:59 +01:00
|
|
|
User.create(
|
2015-03-20 04:20:39 +01:00
|
|
|
uid: "testUser#{i}",
|
2015-03-19 17:38:59 +01:00
|
|
|
avatar: users[0][:avatar],
|
|
|
|
password: DEFAULT_PASSWORD,
|
|
|
|
)
|
2015-03-19 16:22:55 +01:00
|
|
|
end
|