I'm having a problem while deploying an api in Rails on Heroku. In the development environment it works perfectly and my data placed through db:seed is in the database. After doing the deploy on heroku, I ran the db:migrate command and my bank is empty and when running db:seed, the server returns http 500 error. Am I doing any wrong process? is there a possibility to use db: seed in heroku?
Product.destroy_all
ProductCategory.destroy_all
Restaurant.destroy_all
Category.destroy_all
path_image = 'public/images/categories/mexican.jpg'
c = Category.create(id: 1, title: 'mexican')
c.image.attach(io: File.open(path_image), filename: 'mexican.jpg')
path_image = 'public/images/categories/italian.jpeg'
c = Category.create(id: 2, title: 'italian')
c.image.attach(io: File.open(path_image), filename: 'italian.jpeg')
path_image = 'public/images/categories/japonese.jpeg'
c = Category.create(id: 3, title: 'japanese')
c.image.attach(io: File.open(path_image), filename: 'japanese.jpeg')
path_image = 'public/images/categories/vegan.jpeg'
c = Category.create(id: 4, title: 'vegan')
c.image.attach(io: File.open(path_image), filename: 'vegan.jpeg')
尝试,heroku运行rails db:seed
first make sure you do heroku rails db:migrate
then do heroku rails db:seed
.
If you are writing directly on heroku terminal you don't need the "heroku" just rails db:migrate
and rails db:seed
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.