如何把seed.rb推到Heroku上

解法思路

在seed.rb 里输入

#账户的写法
#管理员账户
create_account = User.create([email: '[email protected]', password:'123456', password_confirmation: '123456', is_admin: 'true'])
puts "Admin account created."

#一般账户
create_account = User.create([email: '[email protected]', 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"
如何把seed.rb推到Heroku上_第1张图片

在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
如何把seed.rb推到Heroku上_第2张图片

你可能感兴趣的:(如何把seed.rb推到Heroku上)