在heroku上部署rails应用程序

发布于 2024-10-08 21:24:23 字数 676 浏览 0 评论 0原文

嘿 恐怕我应该问一个菜鸟问题:

将我的应用程序推送到 heroku 后。我收到没有数据库的错误

这是我使用的命令

heroku rake 数据库:迁移

我的应用程序可以在本地运行,没有问题,但我注意到数据库文件仅在开发中。 我的测试环境仅使用 rails serverlocalhost:3000

有人告诉我如何在 heroku 中使数据库处于生产模式。

谢谢

,这是heroku日志文件:

这是日志

开始获取“/drummers/1” 221.9.247.14 at Sat Dec 18 06:17:40 -0800 2010 由 DrummersController 处理#show as HTML 参数:{"id"=>"1"} 完成于 167毫秒

ActiveRecord::RecordNotFound(无法 找到 ID=1 的鼓手): 应用程序/控制器/drummers_controller.rb:11:in `显示'

我认为可能是由于数据库,配置文件,变成我在本地测试中使用sqlite3,并且所有迁移文件都是开发前缀,

Hey
I'm afraid I should ask a rookie question :

After push my app to heroku. I got error of no database

This is the command I use

heroku rake 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

anyone tell me how to make the database in production mode in heroku.

Thanks

here's the heroku log file:

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

ActiveRecord::RecordNotFound (Couldn't
find Drummer with ID=1):
app/controllers/drummers_controller.rb:11:in
`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,

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

往事风中埋 2024-10-15 21:24:23

它并不是告诉您没有数据库。

它告诉您无法找到特定记录。

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

您可能有执行 Drummer.find(1) 的代码,但您的生产环境中不存在该代码。

建议您:

  • 创建一个种子文件 (heroku rake db:seed) railscast
  • 推送您的整个数据库到heroku (heroku db:push) [确保您了解这会清除您的生产数据库]

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.

Recommend you either:

  • create a seeds file (heroku rake db:seed) rails cast
  • push your entire database to heroku (heroku db:push) [make sure you understand this will wipe out your production database]
屋顶上的小猫咪 2024-10-15 21:24:23

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

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:

git init
git add .
git commit -m "initial import"
heroku create
git push heroku master
heroku rake db:migrate
heroku open
一绘本一梦想 2024-10-15 21:24:23

我相信,如果您没有根据 文档

I believe Heroku creates a new database.yml for you on deploy if you have no production according to the Docs.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文