bookstore/db/seeds.rb

72 lines
1.2 KiB
Ruby
Raw Normal View History

2021-03-19 17:31:38 +02:00
books = Book.create([
{
title: 'Journey to the Center of the Earth',
price: 10900,
2021-03-22 01:24:13 +01:00
published: true,
quantity: 100
2021-03-19 17:31:38 +02:00
},
{
title: 'From the Earth to the Moon',
price: 6300,
2021-03-22 01:24:13 +01:00
published: false,
quantity: 0
2021-03-19 17:31:38 +02:00
},
{
title: 'Imaginary trip',
price: 3600,
2021-03-22 01:24:13 +01:00
published: true,
2021-03-22 02:25:17 +01:00
quantity: 1
},
{
title: 'Winnie the Pooh',
price: 3700,
published: true,
quantity: 5
2021-03-19 17:31:38 +02:00
},
])
authors = Author.create([
{
first_name: 'Jules',
last_name: 'Verne'
},
{
first_name: 'Dick',
last_name: 'Pick',
},
{
first_name: 'Rick',
last_name: 'Pickle'
},
2021-03-22 02:25:17 +01:00
{
first_name: 'Alan',
last_name: 'Milne'
},
2021-03-19 17:31:38 +02:00
])
2021-03-21 20:30:25 +01:00
books.first.authors << authors.first
books.second.authors << authors.first
books.third.authors << authors.second
books.third.authors << authors.third
2021-03-22 02:25:17 +01:00
books.fourth.authors << authors.fourth
2021-03-21 20:30:25 +01:00
User.create([
2021-03-19 17:31:38 +02:00
{
2021-03-21 20:30:25 +01:00
email: 'abc@o2.pl',
password: 'aaaaaaaa',
2021-03-21 23:43:09 +01:00
role: :admin,
status: :ready
2021-03-19 17:31:38 +02:00
},
{
2021-03-21 20:30:25 +01:00
email: 'abcd@o2.pl',
password: 'aaaaaaaa',
2021-03-21 23:43:09 +01:00
role: :customer,
status: :ready
2021-03-19 17:31:38 +02:00
},
{
2021-03-21 20:30:25 +01:00
email: 'abcde@o2.pl',
password: 'aaaaaaaa',
2021-03-21 23:43:09 +01:00
role: :customer,
status: :ready
2021-03-19 17:31:38 +02:00
},
])