简体   繁体   English

在heroku上部署Rails应用

[英]deploy rails app on heroku

Hey I'm afraid I should ask a rookie question : 嘿,我应该问一个菜鸟问题:

After push my app to heroku. 将我的应用程序推送到heroku之后。 I got error of no database 我没有数据库错误

This is the command I use 这是我使用的命令

heroku rake db:migrate heroku耙db:migrate

My app can run locally with no problem, but I notice the database file only in development. 我的应用程序可以在本地运行,没有问题,但是我注意到数据库文件仅在开发中。 and my test evironment only use rails server and localhost:3000 而我的测试环境仅使用rails serverlocalhost:3000

anyone tell me how to make the database in production mode in heroku. 有人告诉我如何在heroku中将数据库制作为生产模式。

Thanks 谢谢

here's the heroku log file: 这是heroku日志文件:

here's the logs 这是日志

Started GET "/drummers/1" for 221.9.247.14 at Sat Dec 18 06:17:40 -0800 2010 Processing by DrummersController#show as HTML Parameters: {"id"=>"1"} Completed in 167ms 于22年12月18日星期六06:17:40 -0800从221.9.247.14开始GET“ / drummers / 1”,由DrummersController#show处理为HTML参数:{“ id” =>“ 1”}耗时167ms

ActiveRecord::RecordNotFound (Couldn't find Drummer with ID=1): app/controllers/drummers_controller.rb:11:in `show' ActiveRecord :: RecordNotFound(找不到ID = 1的鼓手):app / controllers / drummers_controller.rb:11:在“ show”中

I think it may due to the datebase,config file, become I use sqlite3 in local test, and all the migration file is development prefix, 我认为这可能是由于datebase,config文件导致,我在本地测试中使用了sqlite3,并且所有迁移文件都是开发前缀,

It's not telling you that you have no Database. 这并不是在告诉您您没有数据库。

It's telling you that it can't find a specific record 告诉您找不到特定记录

(Couldn't find Drummer with ID=1): 

It's likely that you have code that's doing Drummer.find(1) and that doesn't exist on your production environment. 您的代码可能正在执行Drummer.find(1) ,而生产环境中不存在。

Recommend you either: 推荐您之一:

  • create a seeds file (heroku rake db:seed) rails cast 创建一个种子文件(Heroku的耙分贝:种子) 轨投
  • push your entire database to heroku (heroku db:push) [make sure you understand this will wipe out your production database] 将整个数据库推送到heroku(heroku db:push)[确保您了解这将清除生产数据库]

Heroku creates a database for each application deployed to it (no need to run heroku rake db:create . Here are the commands you should be using to deploy a Rails application to Heroku: Heroku为部署到它的每个应用程序创建一个数据库(无需运行heroku rake db:create 。这是将Rails应用程序部署到Heroku时应使用的命令:

git init
git add .
git commit -m "initial import"
heroku create
git push heroku master
heroku rake db:migrate
heroku open

如果您没有根据Docs的要求,我相信Heroku会在部署时为您创建一个新的database.yml。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM