“我们很抱歉,但出了问题。”部署到Heroku后 [英] "We're sorry, but something went wrong." after deployment to Heroku

查看:109
本文介绍了“我们很抱歉,但出了问题。”部署到Heroku后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我制作了一个小应用程序,用户可以登录/注销,创建等等。我使用MySQL作为数据库,在本地环境中一切正常。但是在我将它部署到heroku并迁移数据库之后,heroku版本不起作用。

  2011-10-20T18:48:22 + 00:00 app [ web.1]:在2011-10-20 11:48:22 -0700 
2011-10-20T18:48:22 + 00:00应用[web.1]中开始获取/为83.233.57.240 :通过HomeController处理#index为HTML
2011-10-20T18:48:22 + 00:00 app [web.1]:渲染布局/应用程序中的home / index.html.erb(0.0ms)
2011-10-20T18:48:22 + 00:00 app [web.1]:在2ms内完成500次内部服务器错误
2011-10-20T18:48:22 + 00:00 app [web。 1]:
2011-10-20T18:48:22 + 00:00 app [web.1]:ActionView :: Template :: Error(defaults.js未预编译):
2011- 10-20T18:48:22 + 00:00 app [web.1]:3:< head>
2011-10-20T18:48:22 + 00:00 app [web.1]:4:< title><%= content_for?(:title)? yield(:title):无标题%>< /标题>
2011-10-20T18:48:22 + 00:00 app [web.1]:5:<%= stylesheet_link_tagapplication%>
2011-10-20T18:48:22 + 00:00 heroku [路由器]:GET下午--lightning2154.heroku.com/ dyno = web.1队列= 0等待= 0ms服务= 7ms状态= 500 bytes = 728
2011-10-20T18:48:22 + 00:00 app [web.1]:6:<%= javascript_include_tag:defaults%>
2011-10-20T18:48:22 + 00:00 app [web.1]:7:<%= csrf_meta_tag%>
2011-10-20T18:48:22 + 00:00 app [web.1]:8:<%= yield(:head)%>
2011-10-20T18:48:22 + 00:00 app [web.1]:9:< / head>
2011-10-20T18:48:22 + 00:00 app [web.1]:app / views / layouts / application.html.erb:6:in _app_views_layouts_application_html_erb___2280146998680186378_39052620'
2011-10- 20T18:48:22 + 00:00应用[web.1]:
2011-10-20T18:48:22 + 00:00应用[web.1]:
2011-10-20T18: 48:22 + 00:00 app [web.1]:cache:[GET /] miss

我可以看到它在某个时刻完成了500错误,但我不知道为什么。对此有何建议?

解决方案

检查你是否在config / environments / production中有这个

 #如果预编译的资产不存在,则回退到资产管道
config.assets.compile = true

基本上你的问题是你的资产没有被自动编译。

更多信息请点击: http:// devcenter。 heroku.com/articles/rails31_heroku_cedar



编辑:

从Rails 3.1开始,我们将正在使用资产管道。这意味着您需要将所有资源(图像,JavaScript,css)放在 app / assets 中。在3.1之前将把它们放在 public / ** / * 中。

在开发模式下,Rails 3.1将自动编译(缩小JS和CSS,在某些情况下将图像转换为base64等),创建一个小的,

举一个实际的例子,在你的项目中运行 bundle exec rake assets:precompile 。查看 public / 中的新文件夹。您可以安全地将其删除。



在生产模式下,这不是自动的。您可以启用资产的自动编译,也可以在部署前手动运行 bundle exec rake assets:precompile

有关资产管道的更多信息
http://guides.rubyonrails.org/asset_pipeline.html



有用的: https://github.com/dnagir/guard-rails-assets


I've made a minor app, where a user can log in/out, be created and so forth. I'm using mySQL as the database and everything is working fine in local environment. But after I've deployed it to heroku and migrated the database and so forth, the heroku version doesn't work. I'm getting this when I tail the log:

2011-10-20T18:48:22+00:00 app[web.1]: Started GET "/" for 83.233.57.240 at 2011-10-20 11:48:22 -0700
2011-10-20T18:48:22+00:00 app[web.1]:   Processing by HomeController#index as HTML
2011-10-20T18:48:22+00:00 app[web.1]: Rendered home/index.html.erb within layouts/application (0.0ms)
2011-10-20T18:48:22+00:00 app[web.1]: Completed 500 Internal Server Error in 2ms
2011-10-20T18:48:22+00:00 app[web.1]: 
2011-10-20T18:48:22+00:00 app[web.1]: ActionView::Template::Error (defaults.js isn't precompiled):
2011-10-20T18:48:22+00:00 app[web.1]:     3:   <head>
2011-10-20T18:48:22+00:00 app[web.1]:     4:     <title><%= content_for?(:title) ? yield(:title) : "Untitled" %></title>
2011-10-20T18:48:22+00:00 app[web.1]:     5:     <%= stylesheet_link_tag "application" %>
2011-10-20T18:48:22+00:00 heroku[router]: GET afternoon-lightning-2154.heroku.com/ dyno=web.1 queue=0 wait=0ms service=7ms status=500 bytes=728
2011-10-20T18:48:22+00:00 app[web.1]:     6:     <%= javascript_include_tag :defaults %>
2011-10-20T18:48:22+00:00 app[web.1]:     7:     <%= csrf_meta_tag %>
2011-10-20T18:48:22+00:00 app[web.1]:     8:     <%= yield(:head) %>
2011-10-20T18:48:22+00:00 app[web.1]:     9:   </head>
2011-10-20T18:48:22+00:00 app[web.1]:   app/views/layouts/application.html.erb:6:in `_app_views_layouts_application_html_erb___2280146998680186378_39052620'
2011-10-20T18:48:22+00:00 app[web.1]: 
2011-10-20T18:48:22+00:00 app[web.1]: 
2011-10-20T18:48:22+00:00 app[web.1]: cache: [GET /] miss

I can see that it completes the 500 error at some point, but I have no idea why. Any suggestions to this? Thanks in advance!

解决方案

Check that you have this in config/environments/production

# Fallback to assets pipeline if a precompiled asset is missed
config.assets.compile = true

Basically your problem is that your assets are not being automatically compiled.

More info here: http://devcenter.heroku.com/articles/rails31_heroku_cedar

Edit:

From Rails 3.1 we are going to be using the Assets pipeline. This means that you need to put all your assets (images, javascript, css) in app/assets. Prior to 3.1 to would put those in public/**/*.

In development mode Rails 3.1 is going to automatically compile ( minify both JS and CSS, transform images to base64 in some cases, etc) all your assets, creating a small, versioned package.

For a practical example, run bundle exec rake assets:precompile in your project. Take a look at the new folder in public/. You can safely delete it after.

In production mode this is not automatic. You may either enable automatic compilation of the assets, or manually run bundle exec rake assets:precompile before deployment.

More info on the Assets Pipeline http://guides.rubyonrails.org/asset_pipeline.html

Useful: https://github.com/dnagir/guard-rails-assets

这篇关于“我们很抱歉,但出了问题。”部署到Heroku后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆