尝试将一个非常基本的rails应用程序部署到Heroku。它在sqlite3上运行,我在部署它时遇到了一些问题。
首先,我确保gem上市的sqlite3正在开发中。这使得索引页面终于可以工作了,但现在当我部署它并尝试按照链接访问页面中实际依赖于我的数据库的部分时,heroku错误。我盯着日志看了一会儿,不知道发生了什么,所以我希望这里有人能这样做。我现在只发布最后一个动作的日志(链接后):
2012-09-13T01:00:23+00:00 heroku[router]: GET bloc-blog-1.herokuapp.com/ dyno=web.1 queue=0 wait=0ms service=187ms status=200 bytes=531
2012-09-13T01:00:24+00:00 heroku[router]: GET bloc-blog-1.herokuapp.com/assets/application-0149f820dbdd285aa65e241569d8c256.css dyno=web.1 queue=0 wait=0ms service=9ms status=200 bytes=811
2012-09-13T01:00:24+00:00 heroku[router]: GET bloc-blog-1.herokuapp.com/assets/application-1c74ddb87f4b5b3c36c58d068d148c95.js dyno=web.1 queue=0 wait=0ms service=9ms status=200 bytes=99469
2012-09-13T01:00:27+00:00 app[web.1]:
2012-09-13T01:00:27+00:00 app[web.1]:
2012-09-13T01:00:27+00:00 app[web.1]: Started GET "/posts" for 50.131.223.42 at 2012-09-13 01:00:27 +0000
2012-09-13T01:00:27+00:00 app[web.1]: Processing by PostsController#index as HTML
2012-09-13T01:00:27+00:00 app[web.1]: Completed 500 Internal Server Error in 75ms
2012-09-13T01:00:27+00:00 app[web.1]:
2012-09-13T01:00:27+00:00 app[web.1]: LINE 4: WHERE a.attrelid = '"posts"'::regclass
2012-09-13T01:00:27+00:00 app[web.1]: ^
2012-09-13T01:00:27+00:00 app[web.1]: : SELECT a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a.attnotnull
2012-09-13T01:00:27+00:00 app[web.1]: FROM pg_attribute a LEFT JOIN pg_attrdef d
2012-09-13T01:00:27+00:00 app[web.1]: ActiveRecord::StatementInvalid (PG::Error: ERROR: relation "posts" does not exist
2012-09-13T01:00:27+00:00 app[web.1]: ON a.attrelid = d.adrelid AND a.attnum = d.adnum
2012-09-13T01:00:27+00:00 app[web.1]: WHERE a.attrelid = '"posts"'::regclass
2012-09-13T01:00:27+00:00 app[web.1]: ):
2012-09-13T01:00:27+00:00 app[web.1]:
2012-09-13T01:00:27+00:00 app[web.1]: app/controllers/posts_controller.rb:5:in `index'
2012-09-13T01:00:27+00:00 app[web.1]: AND a.attnum > 0 AND NOT a.attisdropped
2012-09-13T01:00:27+00:00 app[web.1]:
2012-09-13T01:00:27+00:00 app[web.1]: ORDER BY a.attnum
2012-09-13T01:00:27+00:00 heroku[router]: GET bloc-blog-1.herokuapp.com/posts dyno=web.1 queue=0 wait=0ms service=86ms status=500 bytes=643
谢谢!
Heroku使用PostgreSQL。按照Rails教程中的说明在本地安装PostgreSQL,这样您就可以复制Heroku DB环境。Heroku本身以及几乎所有的教程都警告说,在sqlite3中开发然后部署到PostgreSQL充满了危险。