Ruby-on-rails Heroku - 应用程序错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7953933/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 02:16:07  来源:igfitidea点击:

Heroku - Application Error

ruby-on-railsheroku

提问by ruhungry

I've created simple application with Ruby on Rails and I've tried to commit it on Heroku. I've followed this Getting Started on Heroku guide, I finished it and try to open my page but I still see an Error: Application Error:

我已经使用 Ruby on Rails 创建了简单的应用程序,并尝试在 Heroku 上提交它。我已经按照Heroku 入门指南进行了操作,我完成了它并尝试打开我的页面,但我仍然看到一个错误:应用程序错误:

An error occurred in the application and your page could not be served. Please try again in a few moments.

If you are the application owner, check your logs for details.

应用程序发生错误,无法提供您的页面。请稍后重试。

如果您是应用程序所有者,请检查您的日志以了解详细信息。

Anybody know how to deal with it?

有人知道怎么处理吗?



I don't know what was happen but I've done this step, unfortunately I have another problem, I run a few commands:

我不知道发生了什么,但我已经完成了这一步,不幸的是我还有另一个问题,我运行了一些命令:

# git add .
# git commit -m "my commit"
On branch master nothing to commit (working directory clean)
# git push heroku masterEverything up-to-date
# heroku openOpening http ://eerie-meadow-9207.heroku.com/
# heroku restartRestarting processes... done
# heroku openOpening http ://eerie-meadow-9207.heroku.com/

# git 添加。
# git commit -m "my commit"
在分支 master 上没有什么可提交的(工作目录干净)
# git push heroku master一切都是最新的
# heroku open打开 http://eerie-meadow-9207.heroku.com/
# heroku restart重新启动进程... done
# heroku open打开 http://eerie-meadow-9207.heroku.com/

And I see a message:

我看到一条消息:

We're sorry, but something went wrong.

We've been notified about this issue and we'll take a look at it shortly.

我们很抱歉,但有些不对劲。

我们已收到有关此问题的通知,我们很快就会对其进行研究。

From heroku logs[timestamps removed for clarity]:

heroku logs[为清晰起见删除时间戳]

app[web.1]: Started GET "/" for 77.236.11.34 at 2011-10-31 11:50:38 -0700
app[web.1]:   Processing by StoreController#index as HTML
app[web.1]: Completed 500 Internal Server Error in 3ms
heroku[router]: GET eerie-meadow-9207.heroku.com/ dyno=web.1 queue=0 wait=0ms service=13ms status=500 bytes=728
heroku[nginx]: 77.236.11.34 - - [31/Oct/2011:11:50:38 -0700] "GET / HTTP/1.1" 500 728 "-" "Mozilla/5.0 (X11; U; Linux i686; pl-PL; rv:1.9.2.23) Gecko/20110921 Ubuntu/10.04 (lucid) Firefox/3.6.23" eerie-meadow-9207.heroku.com
app[web.1]:
heroku[web.1]: State changed from up to bouncing
heroku[web.1]: State changed from bouncing to created
heroku[web.1]: State changed from created to starting
heroku[web.1]: Starting process with command `thin -p 40376 -e production -R /home/heroku_rack/heroku.ru start`
heroku[web.1]: Process exited
app[web.1]: >> Maximum connections set to 1024 
app[web.1]: >> Listening on 0.0.0.0:40376, CTRL+C to stop
app[web.1]: >> Thin web server (v1.2.6 codename Crazy Delicious)
heroku[web.1]: State changed from starting to up
app[web.1]:
app[web.1]: Started GET "/" for 77.236.11.34 at 2011-10-31 11:50:59-0700
app[web.1]:
app[web.1]:   Processing by StoreController#index as HTML
app[web.1]: Completed 500 Internal Server Error in 4ms
app[web.1]:
app[web.1]: ActiveRecord::StatementInvalid (PGError: ERROR:  relation "products" does not exist
app[web.1]: :             SELECT a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a.attnotnull
app[web.1]:               FROM pg_attribute a LEFT JOIN pg_attrdef d
app[web.1]:         ON a.attrelid = d.adrelid AND a.attnum = d.adnum
app[web.1]:              WHERE a.attrelid = '"products"'::regclass
app[web.1]:           AND a.attnum > 0 AND NOT a.attisdropped
app[web.1]:              ORDER BY a.attnum
app[web.1]: ):
app[web.1]:   app/controllers/store_controller.rb:3:in `index'
app[web.1]:
app[web.1]:
app[web.1]: cache: [GET /] miss
heroku[router]: GET eerie-meadow-9207.heroku.com/ dyno=web.1 queue=0 wait=0ms service=81ms status=500 bytes=728
heroku[nginx]: 77.236.11.34 - - [31/Oct/2011:11:50:59 -0700] "GET / HTTP/1.1" 500 728 "-" "Mozilla/5.0 (X11; U; Linux i686; pl-PL; rv:1.9.2.23) Gecko/20110921 Ubuntu/10.04 (lucid) Firefox/3.6.23" eerie-meadow-9207.heroku.com
app[web.1]:
app[web.1]:
app[web.1]: Started GET "/" for 77.236.11.34 at 2011-10-31 11:54:00-0700
app[web.1]:   Processing by StoreController#index as HTML

I cannot understand it because on my netbook it works on localhost, any ideas?

我无法理解它,因为在我的上网本上它可以在本地主机上运行,​​有什么想法吗?

采纳答案by demental

Most of the time heroku issues are due to lack of privileges to access file system. In order for your application to work on heroku you must make sure it wont try to write anything to disk (but in temporary folder).

大多数情况下,heroku 问题是由于缺乏访问文件系统的权限。为了让您的应用程序在 heroku 上工作,您必须确保它不会尝试将任何内容写入磁盘(但在临时文件夹中)。

The typical example is js/css compiling process, e.g. with compass, for which you will find a solution on their knowledge database: http://devcenter.heroku.com/articles/using-compass

典型的例子是 js/css 编译过程,例如使用指南针,您可以在他们的知识库中找到解决方案:http: //devcenter.heroku.com/articles/using-compass

You should look further in the heroku logs see if there is any "permission denied" issue at application startup or during the first requests.

您应该进一步查看 heroku 日志,看看在应用程序启动时或第一次请求期间是否存在任何“权限被拒绝”问题。

回答by shal

Try using the command

尝试使用命令

heroku run rake db:migrate

heroku run rake db:migrate

回答by Ariejan

Try restarting your app with heroku restart. Assuming your app runs fine locally, this should do the trick. It solved the issue for me as I only refactored the schema and the db:reset did not seem to do the trick.

尝试使用 重新启动您的应用程序heroku restart。假设您的应用程序在本地运行良好,这应该可以解决问题。它为我解决了这个问题,因为我只重构了架构,而 db:reset 似乎没有解决问题。

回答by Dru

http://www.youtube.com/watch?v=p_3dIPgXgkg

http://www.youtube.com/watch?v=p_3dIPgXgkg

If you already have your application built, go to the point in the video when he begins pushing the sample app to heroku. Unfortunately heroku returns hard to solve errors when uploading 3.1 apps for the first time. Follow the troubleshooting steps in the video and you'll be fine.

如果您已经构建了应用程序,请转到视频中他开始将示例应用程序推送到 heroku 时的点。不幸的是,heroku 在第一次上传 3.1 应用程序时返回难以解决的错误。按照视频中的故障排除步骤操作,您会没事的。

回答by Elias Prado

I had the same problem. Have a look at your Procfile and check if you have added the proper command in it such as web: python run.py. I wasn't able to connect then I placed the command heroku logs --tailto see what was the problem and I saw that within my Procfile I had a type mistake such as >>>web: oython run.py<<< making the app not work. So, pay attention to it. command: $echo web: python run.py > Procfile

我有同样的问题。查看您的 Procfile 并检查您是否在其中添加了正确的命令,例如web: python run.py. 我无法连接然后我放置命令heroku logs --tail以查看问题所在,并且我看到在我的 Procfile 中我有一个类型错误,例如 >>> web: oython run.py<<< 使应用程序无法运行。所以,要注意它。命令:$echo web: python run.py > Procfile