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-23 11:54:15 +01:00
|
|
|
require 'faker'
|
|
|
|
require 'identicon'
|
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 = [
|
|
|
|
{
|
2015-03-26 12:45:45 +01:00
|
|
|
name: "Twix",
|
|
|
|
price: 0.4,
|
|
|
|
category: "food",
|
|
|
|
stock: 0,
|
|
|
|
avatar: File.new('public/seeds/products/1.jpg', 'r')
|
2015-03-19 16:22:55 +01:00
|
|
|
},
|
|
|
|
{
|
2015-03-26 12:45:45 +01:00
|
|
|
name: "M&M Peanuts",
|
|
|
|
price: 0.6,
|
|
|
|
category: "food",
|
|
|
|
stock: 0,
|
|
|
|
avatar: File.new('public/seeds/products/2.jpg', 'r')
|
2015-03-19 16:22:55 +01:00
|
|
|
},
|
|
|
|
{
|
2015-03-26 12:45:45 +01:00
|
|
|
name: "Snickers",
|
|
|
|
price: 0.4,
|
|
|
|
category: "food",
|
|
|
|
stock: 0,
|
|
|
|
avatar: File.new('public/seeds/products/3.jpg', 'r')
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Fanta",
|
|
|
|
price: 0.6,
|
|
|
|
category: "beverages",
|
|
|
|
stock: 0,
|
|
|
|
avatar: File.new('public/seeds/products/4.jpg', 'r')
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Ice Tea",
|
|
|
|
price: 0.7,
|
|
|
|
category: "beverages",
|
|
|
|
stock: 0,
|
|
|
|
avatar: File.new('public/seeds/products/5.jpg', 'r')
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Cola",
|
|
|
|
price: 0.6,
|
|
|
|
category: "beverages",
|
|
|
|
stock: 0,
|
|
|
|
avatar: File.new('public/seeds/products/6.jpg', 'r')
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Abrikozencake",
|
|
|
|
price: 0.4,
|
|
|
|
category: "food",
|
|
|
|
stock: 0,
|
|
|
|
avatar: File.new('public/seeds/products/7.jpg', 'r')
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Kinder Delice",
|
|
|
|
price: 0.4,
|
|
|
|
category: "food",
|
|
|
|
stock: 0,
|
|
|
|
avatar: File.new('public/seeds/products/8.jpg', 'r')
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Kinder Bueno",
|
|
|
|
price: 0.6,
|
|
|
|
category: "food",
|
|
|
|
stock: 0,
|
|
|
|
avatar: File.new('public/seeds/products/9.jpg', 'r')
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Arizona Ice Tea",
|
|
|
|
price: 1.0,
|
|
|
|
category: "beverages",
|
|
|
|
stock: 0,
|
|
|
|
avatar: File.new('public/seeds/products/10.png', 'r')
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Dinosauruskoeken",
|
|
|
|
price: 0.5,
|
|
|
|
category: "food",
|
|
|
|
stock: 0,
|
|
|
|
avatar: File.new('public/seeds/products/11.jpg', 'r')
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Chocolade - melk",
|
|
|
|
price: 0.7,
|
|
|
|
category: "food",
|
|
|
|
stock: 0,
|
|
|
|
avatar: File.new('public/seeds/products/12.jpg', 'r')
|
2015-03-19 16:22:55 +01:00
|
|
|
}
|
|
|
|
]
|
|
|
|
|
|
|
|
products.each do |attr|
|
|
|
|
Product.create name: attr[:name], price: attr[:price], category: attr[:category], stock: attr[:stock], avatar: attr[:avatar]
|
|
|
|
end
|
|
|
|
|
2015-03-25 17:49:37 +01:00
|
|
|
User.create(
|
|
|
|
uid: "koelkast",
|
|
|
|
password: "password",
|
|
|
|
password_confirmation: "password",
|
|
|
|
avatar: Identicon.data_url_for("koelkast"),
|
|
|
|
koelkast: true
|
|
|
|
)
|
|
|
|
|
2015-03-23 11:54:15 +01:00
|
|
|
20.times do |i|
|
|
|
|
name = Faker::Name.name
|
2015-03-19 17:38:59 +01:00
|
|
|
User.create(
|
2015-03-23 11:54:15 +01:00
|
|
|
uid: name,
|
|
|
|
avatar: Identicon.data_url_for(name)
|
2015-03-19 17:38:59 +01:00
|
|
|
)
|
2015-03-19 16:22:55 +01:00
|
|
|
end
|