解法思路
在seed.rb 里输入
#账户的写法
#管理员账户
create_account = User.create([email: 'mjadmin@jdstore3.com', password:'123456', password_confirmation: '123456', is_admin: 'true'])
puts "Admin account created."
#一般账户
create_account = User.create([email: 'mjuser@jdstore3.com', password:'123456', password_confirmation: '123456', is_admin: 'false'])
puts "User account created."
#产品的写法
Product.create!(title: "Cup",
description: "Nice Cup",
price: 80,
quantity: 10,
image: open("http://ot4s5c6m1.bkt.clouddn.com/cup-glass-03.jpg")
)
puts "Product created"
Product.create!(title: "Pen",
description: "Wow Pen",
price: 20,
quantity: 100,
image: open("http://ot4s5c6m1.bkt.clouddn.com/Pen.jpeg")
)
puts "Product created"
在terminal 里输入
rake db:seed
git add .
git commit -m "Add account and product to seed"
git push origin qiniu
git push heroku qiniu:master
heroku rake db:migrate
heroku rake db:seed
网友评论