2

我被推荐给 Heroku 以进行 Ruby on Rails 托管,到目前为止,我想我真的会喜欢它。只是想知道是否有人可以帮助我找出问题所在。

我按照那里的说明在该站点上创建应用程序,创建并提交 git,推送代码并显示在http://mylifebattlecry.heroku.com上(尽管我所做的大部分工作都在 /posts/ 路径中)当我进入一个新的“帖子”(因为这是一个博客平台)时,我得到了 500.html 错误,基本上一切都关闭了。甚至无法回到我输入帖子的页面。

在我看来,数据库设置有问题。我按照他们的建议做了,包括 ...$ heroku rake db:migrate,什么都没有。

只是想知道是否有人知道我做错了什么。以下是他们提供的参考说明:

安装 Heroku gem:sudo gem install heroku为你的应用创建一个新的 git 仓库(如果你还没有):

cd myapp
git init && git add . && git commit -m "first commit"

创建一个新的 Heroku 应用程序:

heroku create
Created http://sharp-autumn-42.com/ | git@heroku.com:sharp-autumn-42.git
Git remote heroku added

注意:应用程序的名称是自动生成的;不用担心,您可以随时重命名。

部署您的代码:

git push heroku master

运行迁移(或其他引导任务):

heroku rake db:migrate

在浏览器中打开已部署的应用程序:heroku open

如果有帮助,这里是 ..$ heroku 日志:

brandon-gadocis-macbook-pro:mylifebattlecry bgadoci$ heroku logs -app mylifebattlecry
==> dyno-629271.log <==

==> production.log <==
# Logfile created on Sun Nov 22 18:26:06 -0800 2009

Processing PostsController#index (for 99.7.50.140 at 2009-11-22 18:26:07) [GET]
Rendering template within layouts/posts
Rendering posts/index

ActionView::TemplateError (PGError: ERROR:  column votes.post_id does not exist
LINE 1: SELECT count(*) AS count_all FROM "votes" WHERE ("votes".pos...
                                                         ^
: SELECT count(*) AS count_all FROM "votes" WHERE ("votes".post_id = 1) ) on line #58 of app/views/posts/index.html.erb:
55:                 </div>
56:             <div id="vote"><br/>
57:                 <div id="votes">
58:                     <%= pluralize post.votes.count, 'Person' %>  like the above BattleCry. <br/>
59:                 </div>
60:                 <%= link_to "Comments (#{post.comments.count})", post %>
61:             </div>

    app/views/posts/index.html.erb:58
    app/views/posts/index.html.erb:51
    app/views/posts/index.html.erb:45:in `each'
    app/views/posts/index.html.erb:45
    app/controllers/posts_controller.rb:11:in `index'
    /home/heroku_rack/lib/static_assets.rb:9:in `call'
    /home/heroku_rack/lib/last_access.rb:25:in `call'
    /home/heroku_rack/lib/date_header.rb:14:in `call'
    thin (1.0.1) lib/thin/connection.rb:80:in `pre_process'
    thin (1.0.1) lib/thin/connection.rb:78:in `catch'
    thin (1.0.1) lib/thin/connection.rb:78:in `pre_process'
    thin (1.0.1) lib/thin/connection.rb:57:in `process'
    thin (1.0.1) lib/thin/connection.rb:42:in `receive_data'
    eventmachine (0.12.6) lib/eventmachine.rb:240:in `run_machine'
    eventmachine (0.12.6) lib/eventmachine.rb:240:in `run'
    thin (1.0.1) lib/thin/backends/base.rb:57:in `start'
    thin (1.0.1) lib/thin/server.rb:150:in `start'
    thin (1.0.1) lib/thin/controllers/controller.rb:80:in `start'
    thin (1.0.1) lib/thin/runner.rb:173:in `send'
    thin (1.0.1) lib/thin/runner.rb:173:in `run_command'
    thin (1.0.1) lib/thin/runner.rb:139:in `run!'
    thin (1.0.1) bin/thin:6
    /usr/local/bin/thin:20:in `load'
    /usr/local/bin/thin:20

Rendering /disk1/home/slugs/88382_601a216_9803/mnt/public/500.html (500 Internal Server Error)
4

4 回答 4

9

您确定您的所有表都有迁移吗?

你可以做 heroku rake db:schema:load 来加载一个新的模式

于 2009-11-23T02:45:47.750 回答
4

日志中的重要行是:

PGError: ERROR: column votes.post_id does not exist

这意味着 Heroku 上的数据库没有您的应用尝试使用的架构。

确保您有一个以您想要的方式创建表的迁移,提交更改,然后运行:heroku rake db:migrate您将完成所有工作。

要测试,从一个干净的本地数据库开始(如果使用 sqlite,只需 nuke db/development.sqlite3),然后在rake db:migrate本地运行。如果它可以在您的本地机器上运行,那么它应该可以在 Heroku 上运行。

于 2009-11-23T05:48:20.543 回答
2

在此过程中没有任何问题,您可以尝试heroku restart重新启动应用程序 - 但最好的办法是heroku logs在加载问题页面后立即执行,然后查看它告诉您的内容。

于 2009-11-23T02:22:11.597 回答
2

我遇到了类似的问题。heroku restart解决了heroku rake db:migrate 没有采取的问题。此外,您可以通过heroku console./script/console在远程应用程序上)检查您的应用程序。

于 2010-01-02T04:06:05.173 回答