【问题标题】:We're sorry, but something went wrong heroku rails很抱歉,出现了问题 heroku rails
【发布时间】:2013-07-14 01:32:08
【问题描述】:

我在使用 heroku 部署 rails 3.2 应用程序时遇到问题,加载应用程序时出现上述错误。这是我的日志:

→ heroku 日志

2013-07-14T01:15:03+00:00 heroku[slug-compiler]: Slug compilation finished
2013-07-14T01:15:11.541229+00:00 heroku[web.1]: Starting process with command `bundle exec     rails server -p 46418`
2013-07-14T01:15:14.054907+00:00 app[web.1]: DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/config/environment.rb:5)
2013-07-14T01:15:14.054907+00:00 app[web.1]: DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/config/environment.rb:5)
2013-07-14T01:15:14.492621+00:00 app[web.1]: => Call with -d to detach
2013-07-14T01:15:14.492621+00:00 app[web.1]: Connecting to database specified by DATABASE_URL
2013-07-14T01:15:14.492621+00:00 app[web.1]: => Rails 3.2.13 application starting in production on http://0.0.0.0:46418
2013-07-14T01:15:14.492621+00:00 app[web.1]: => Ctrl-C to shutdown server
2013-07-14T01:15:14.492621+00:00 app[web.1]: => Booting WEBrick
2013-07-14T01:15:15.901411+00:00 app[web.1]: [2013-07-14 01:15:15] INFO  ruby 2.0.0 (2013-06-27) [x86_64-linux]
2013-07-14T01:15:15.901411+00:00 app[web.1]: [2013-07-14 01:15:15] INFO  WEBrick 1.3.1
2013-07-14T01:15:15.901769+00:00 app[web.1]: [2013-07-14 01:15:15] INFO  WEBrick::HTTPServer#start: pid=2 port=46418
2013-07-14T01:15:16.447320+00:00 heroku[web.1]: State changed from starting to up
2013-07-14T01:15:17.584921+00:00 app[web.1]: Started GET "/" for 71.202.122.134 at 2013-07-14 01:15:17 +0000
2013-07-14T01:15:17.646525+00:00 app[web.1]: Processing by HomeController#index as HTML
2013-07-14T01:15:17.722541+00:00 app[web.1]: Completed 500 Internal Server Error in 76ms
2013-07-14T01:15:17.724418+00:00 app[web.1]:                                         ^
2013-07-14T01:15:17.724418+00:00 app[web.1]: :             SELECT a.attname, format_type(a.atttypid, a.atttypmod),
2013-07-14T01:15:17.724418+00:00 app[web.1]: 
2013-07-14T01:15:17.724418+00:00 app[web.1]: ActiveRecord::StatementInvalid (PG::Error: ERROR:  relation "houses" does not exist
2013-07-14T01:15:17.724588+00:00 app[web.1]: ):
2013-07-14T01:15:17.724588+00:00 app[web.1]: 
2013-07-14T01:15:17.726539+00:00 heroku[router]: at=info method=GET path=/ host=frozen-spire-1369.herokuapp.com fwd="71.202.122.134" dyno=web.1 connect=1ms service=149ms status=500 bytes=643
2013-07-14T01:15:17.724588+00:00 app[web.1]:   app/controllers/home_controller.rb:3:in `index'
2013-07-14T01:15:17.724418+00:00 app[web.1]: LINE 5:              WHERE a.attrelid = '"houses"'::regclass
2013-07-14T01:15:17.724418+00:00 app[web.1]:                AND a.attnum > 0 AND NOT a.attisdropped
2013-07-14T01:15:17.724418+00:00 app[web.1]:               FROM pg_attribute a LEFT JOIN pg_attrdef d
2013-07-14T01:15:17.724418+00:00 app[web.1]:                      pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
2013-07-14T01:15:17.724588+00:00 app[web.1]:              ORDER BY a.attnum
2013-07-14T01:15:17.724418+00:00 app[web.1]:                 ON a.attrelid = d.adrelid AND a.attnum = d.adnum
2013-07-14T01:15:17.724418+00:00 app[web.1]:              WHERE a.attrelid = '"houses"'::regclass
2013-07-14T01:15:17.724588+00:00 app[web.1]: 
2013-07-14T01:15:18.221829+00:00 heroku[router]: at=info method=GET path=/favicon.ico host=frozen-spire-1369.herokuapp.com fwd="71.202.122.134" dyno=web.1 connect=9ms service=17ms status=200 bytes=0
2013-07-14T01:20:10.025198+00:00 app[web.1]: Started GET "/" for 71.202.122.134 at 2013-07-14 01:20:10 +0000
2013-07-14T01:20:10.048127+00:00 heroku[router]: at=info method=GET path=/ host=frozen-spire-1369.herokuapp.com fwd="71.202.122.134" dyno=web.1 connect=2ms service=24ms status=500 bytes=643
2013-07-14T01:20:10.035374+00:00 app[web.1]: Processing by HomeController#index as HTML
2013-07-14T01:20:10.038857+00:00 app[web.1]: Completed 500 Internal Server Error in 3ms
2013-07-14T01:20:10.040758+00:00 app[web.1]: 
2013-07-14T01:20:10.040758+00:00 app[web.1]: ActiveRecord::StatementInvalid (PG::Error: ERROR:  relation "houses" does not exist
2013-07-14T01:20:10.040758+00:00 app[web.1]: LINE 5:              WHERE a.attrelid = '"houses"'::regclass
2013-07-14T01:20:10.040758+00:00 app[web.1]:                                         ^
2013-07-14T01:20:10.040758+00:00 app[web.1]:                      pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
2013-07-14T01:20:10.040758+00:00 app[web.1]:               FROM pg_attribute a LEFT JOIN pg_attrdef d
2013-07-14T01:20:10.040758+00:00 app[web.1]:                 ON a.attrelid = d.adrelid AND a.attnum = d.adnum
2013-07-14T01:20:10.040758+00:00 app[web.1]:              WHERE a.attrelid = '"houses"'::regclass
2013-07-14T01:20:10.040758+00:00 app[web.1]:                AND a.attnum > 0 AND NOT a.attisdropped
2013-07-14T01:20:10.040927+00:00 app[web.1]:              ORDER BY a.attnum
2013-07-14T01:20:10.040927+00:00 app[web.1]: ):
2013-07-14T01:20:10.040927+00:00 app[web.1]: 
2013-07-14T01:20:10.040927+00:00 app[web.1]: 
2013-07-14T01:20:10.040927+00:00 app[web.1]:   app/controllers/home_controller.rb:3:in `index'
2013-07-14T01:20:10.040758+00:00 app[web.1]: :             SELECT a.attname, format_type(a.atttypid, a.atttypmod),
2013-07-14T01:20:10.388132+00:00 heroku[router]: at=info method=GET path=/favicon.ico host=frozen-spire-1369.herokuapp.com fwd="71.202.122.134" dyno=web.1 connect=3ms service=12ms status=304 bytes=0

我对 rails/heroku 还很陌生,因此非常感谢任何帮助。经过大量开发后,我正在尝试部署。对于未来,在开发过程的早期推送到heroku,然后继续推送会更好吗?谢谢!

【问题讨论】:

  • ActiveRecord::StatementInvalid (PG::Error: ERROR: relation "houses" does not exist - 我会说数据库中的房屋表丢失了。
  • 我必须将数据库迁移到heroku服务器吗?如果是这样,我该怎么做?
  • 使用 heroku 工具带,heroku run rake db:create --app my_app2heroku run rake db:migrate --app my_app2。我不是heroku方面的专家,只是用过几次,所以我不能告诉你太多
  • 通过正常部署,迁移将自动运行,因此您不必自己运行它们。
  • 我是这么想的……

标签: ruby-on-rails heroku


【解决方案1】:
  1. ActiveRecord::StatementInvalid(PG::Error: ERROR: 关系“houses”不存在

    我想说数据库中的houses 表丢失了,您可以使用heroku 工具带运行迁移:heroku run rake db:create --app my_app2 - 创建数据库,heroku run rake db:migrate --app my_app2 - 运行迁移。使用 Capistrano 设置部署将通过一个命令为您运行所有内容。

    Heroku 工具带 - https://toolbelt.heroku.com/

    Capistrano - https://github.com/capistrano/capistrano

  2. 对于未来,在开发过程的早期推送到heroku,然后继续推送更好吗?

    在我目前与我们团队合作的项目中,我们有 2 个 heroku 实例,表示 2 个应用,一个用于 production,第二个用于 测试,首先将更改推送到测试应用程序,如果一切顺利,我们将其移至生产环境。

编辑

我发现您正在使用 sqlite 进行开发:

Heroku 使用 postgresql。 https://devcenter.heroku.com/articles/sqlite3

删除 sqlite3 或将其移动到 Gemfile 中的 development group,如下所示:

group :development do
  gem 'sqlite3'
end

group :production do
  gem 'thin'
  gem 'pg'
end

删除 Gemfile.lock 运行bundle install --without production

git add .
git commit -am "bundle updating sqlite3"
git push heroku master

或者更简单,只需在本地计算机上使用 PG 进行开发。你可能有一些 sql 语句可以在 sqlite 中工作,而不能在 heroku 上的 postgres 中工作,所以我会在你的地方使用 PG 进行开发。

【讨论】:

  • 运行 heroku run rake db:create --app my_app2 时出现以下错误:No Rakefile found (looking for: rakefile, Rakefile, rakefile.rb, Rakefile.rb)。进入 heroku 控制台,我的表似乎都不存在。我使用 sqlite 开发应用程序而 heroku 使用 postgre 进行部署会不会是一个问题?
  • 没错,heroku 在 PG 上运行。 devcenter.heroku.com/articles/sqlite3 不知道你的应用在 sql 上
  • 如果对您有帮助,接受答案是很常见的。如果没有,请告诉我,我会删除我的答案,以免其他人感到困惑。
  • 对不起,我对 SO 很陌生,我不知道接受答案。这很有帮助!我并不想转换为 PG 进行开发,事后看来,这从一开始就是一个好主意......
  • 你的应用在 github 上吗?发布它的链接,我会看看你的迁移,会尝试修复它们
猜你喜欢
  • 2012-05-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-08-12
  • 2014-01-22
  • 1970-01-01
  • 2012-07-29
  • 2012-04-19
相关资源
最近更新 更多