我向Heroku推荐了Ruby on Rails托管,到目前为止,我认为我真的会喜欢它。我只是想知道有没有人能帮我找出问题所在。
我按照下面的说明在那里创建一个应用程序,创建并提交git,推送代码,当我进入一个新的“帖子”(因为这是一种博客平台)时,它会显示在http://mylifebattlecry.heroku.com (尽管我所做的大部分工作都在/posts/路径中),我得到了500.html错误,基本上所有的东西都关闭了。我甚至不能回到我进入帖子的页面。
在我看来,数据库设置出了问题。我按照他们的建议做了,包括...$ heroku rake db:迁移,什么都不做。
我只是想知道有没有人知道我做错了什么。以下是他们给出的参考说明:
安装Heroku gem:sudo gem为您的应用程序安装herokuCreate,一个新的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)发布于 2009-11-23 10:45:48
是否确定已对所有表进行了迁移。
您可以执行heroku rake db: schema :load来加载一个新的模式
发布于 2009-11-23 13:48:21
日志中的重要一行是:
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-23 10:22:12
在这个过程中没有任何错误,你可以尝试heroku restart来重启应用程序--但你最好的办法是在加载问题页面之后执行heroku logs,看看它会告诉你什么。
https://stackoverflow.com/questions/1780789
复制相似问题