“很抱歉,出了点问题。”部署到 Heroku 后
我制作了一个小型应用程序,用户可以在其中登录/退出、创建等等。我使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
检查 config/environments/product 中是否有此内容
基本上,您的问题是您的资产没有被自动编译。
更多信息请参见: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
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 inpublic/**/*
.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 inpublic/
. 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