Skip to content
Permalink
Browse files

Nic Live db:Seed

  • Loading branch information...
niclin committed May 15, 2017
1 parent c46d7cf commit 48a4caa69f19021b903f5e132f0612d6f78c8c30
Showing with 35 additions and 6 deletions.
  1. +35 −6 db/seeds.rb
@@ -1,9 +1,38 @@
u = User.new
u.email = "admin@test.com" # 可以改成自己的 email

u.password = "123456" # 最少要六码
# Initialize Admin User
if User.find_by(email: "admin@test.com").nil?
u = User.new
u.email = "admin@test.com" # 可以改成自己的 email
u.password = "123456" # 最少要六码
u.password_confirmation = "123456" # 最少要六码
u.is_admin = true
u.save
puts "Admin 已经建立好了,帐号为#{u.email}, 密码为#{u.password}"
else
puts "Admin 已经建立过了,脚本跳过该步骤。"
end

u.password_confirmation = "123456" # 最少要六码

u.is_admin = true
u.save
# Initialize Product

Product.create!(title: "QC-35",
description: "耳机",
price: 2800,
quantity: 5,
image: open("https://images-cn.ssl-images-amazon.com/images/I/41bVSMLUllL._AC_UL320_SR320,320_.jpg")
)

Product.create!(title: "Iphone7",
description: "手机",
price: 5000,
quantity: 5,
image: open("https://images-cn.ssl-images-amazon.com/images/I/51q3gdJGenL._SL800_.jpg")
)

Product.create!(title: "Cherry Keyboard",
description: "G80-3000键盘",
price: 2800,
quantity: 5,
image: open("https://images-cn.ssl-images-amazon.com/images/I/41LN-bXtA7L._AC_UL320_SR320,320_.jpg")
)

0 comments on commit 48a4caa

Please sign in to comment.
You can’t perform that action at this time.