“很抱歉,出了点问题。”部署到 Heroku 后

发布于 2024-12-11 05:35:35 字数 1742 浏览 0 评论 0原文

我制作了一个小型应用程序,用户可以在其中登录/退出、创建等等。我使用 mySQL 作为数据库,并且在本地环境中一切正常。但是当我将其部署到heroku并迁移数据库等之后,heroku版本不起作用。当我跟踪日志时,我得到了这个:

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

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

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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

忆离笙 2024-12-18 05:35:35

检查 config/environments/product 中是否有此内容

# Fallback to assets pipeline if a precompiled asset is missed
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

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文