gpt4 book ai didi

mysql - "We' 抱歉,出了点问题。”部署到 Heroku 后

转载 作者:可可西里 更新时间:2023-11-01 07:46:43 26 4
gpt4 key购买 nike

我制作了一个小应用程序,用户可以在其中登录/注销、创建等等。我使用 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 错误,但我不知道为什么。对此有何建议?提前致谢!

最佳答案

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

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

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

更多信息在这里:http://devcenter.heroku.com/articles/rails31_heroku_cedar

编辑:

从 Rails 3.1 开始,我们将使用 Assets 管道。这意味着您需要将所有 Assets (图像、javascript、css)放在 app/assets 中。在 3.1 之前会将它们放在 public/**/* 中。

在开发模式下,Rails 3.1 将自动编译(压缩 JS 和 CSS,在某些情况下将图像转换为 base64 等)您的所有 Assets ,创建一个小型的版本包。

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

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

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

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

关于mysql - "We' 抱歉,出了点问题。”部署到 Heroku 后,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7840768/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com