一个有趣的小500错误 [英] An interesting little 500 error
问题描述
heroku日志:
<$ p
我试图部署到Heroku并发生500个服务器错误。 $ p> 开始在### ##。###。###中获得/在2010-10-14 17:59:34 -0700
由WelcomeController处理#index作为HTML
在layouts / index(2.3ms)内渲染welcome / index.html.erb
在3ms中完成
ActionView :: Template :: Error(无法转换零转换为字符串):
5:< meta charset =utf-8>
6:< title> Hello< / title>
7:<%= stylesheet_link_tagglobal,home,:cache => true%>
app / controllers / welcome_controller.rb:5:在'index'中
然后尝试以生产模式启动本地服务器:
$ p code c:\ Sanj\ruby> rails server production
退出
C:/Sanj/Ruby192/lib/ruby/gems/1.9.1/gems/rack-1.2.1/lib/rack/handler.rb:21:在`const_get'中:错误的常量名称生成(NameError )来自C的
:/Sanj/Ruby192/lib/ruby/gems/1.9.1/gems/rack-1.2.1/lib/rack/handler.rb:21:在`get'
从C:/Sanj/Ruby192/lib/ruby/gems/1.9.1/gems/rack-1.2.1/lib/rack/server.rb:217:在`server'
从C:/ Sanj / Ruby192 /lib/ruby/gems/1.9.1/gems/railties-3.0.0/lib/rails/commands/server.rb:54:in`start'
from C:/ Sanj / Ruby192 / lib / ruby /gems/1.9.1/gems/railties-3.0.0/lib/rails/commands.rb:30:in`block in< top(required)>'
from C:/ Sanj / Ruby192 / lib / ruby / gems / 1.9.1 / gems / railties-3.0.0 / lib / rails / commands.rb:27:在'tap'中
从C:/ Sanj / Ruby192 / lib / ruby / gems / 1.9.1 /宝石/ railties-3.0.0 / lib中/导轨/commands.rb:27:in`< top(required)>'脚本/导轨中的
:6:'require'
脚本/导轨中:6:在< main> '
这些问题似乎高度相关 - 您是否知道问题可能出在这里?
非常感谢!
Welcome Controller#index
def索引
render:layout => index
end
请告诉我是否可以提供更多信息。
解决方案
感谢你们的答案。发生此问题的原因是environments / production.rb中的serve_static_assets设置为false。这使系统能够找到明显导致'nil'的CSS文件。我尝试的另一个变化是从样式表中删除:cache => true。
serve_static_assets
问题发生的原因是environments / production.rb中的serve_static_assets设置为 false
。通过更改此选项,系统可以找到试图转换为字符串的'nil'的CSS文件。我还删除了:cache => true
,并且结合起来,这解决了Heroku部署问题。
I just tried to deploy to Heroku and got a 500 server error.
heroku logs:
Started GET "/" for ##.##.###.### at 2010-10-14 17:59:34 -0700
Processing by WelcomeController#index as HTML
Rendered welcome/index.html.erb within layouts/index (2.3ms)
Completed in 3ms
ActionView::Template::Error (can't convert nil into String):
5: <meta charset="utf-8">
6: <title>Hello</title>
7: <%= stylesheet_link_tag "global", "home", :cache => true %>
app/controllers/welcome_controller.rb:5:in `index'
I then tried to start my local server in production mode:
c:\Sanj\ruby>rails server production
Exiting
C:/Sanj/Ruby192/lib/ruby/gems/1.9.1/gems/rack-1.2.1/lib/rack/handler.rb:21:in `const_get': wrong constant name production (NameError)
from C:/Sanj/Ruby192/lib/ruby/gems/1.9.1/gems/rack-1.2.1/lib/rack/handler.rb:21:in `get'
from C:/Sanj/Ruby192/lib/ruby/gems/1.9.1/gems/rack-1.2.1/lib/rack/server.rb:217:in `server'
from C:/Sanj/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.0/lib/rails/commands/server.rb:54:in `start'
from C:/Sanj/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.0/lib/rails/commands.rb:30:in `block in <top (required)>'
from C:/Sanj/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.0/lib/rails/commands.rb:27:in `tap'
from C:/Sanj/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.0/lib/rails/commands.rb:27:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
These issues seem highly related - do you know what the issue might be here?
Thanks very much!
Welcome Controller#index
def index
render :layout => "index"
end
Please tell me if I can supply any more information.
Solution
Thanks to you guys for your answers. The problem was occurring because serve_static_assets was set to false in environments/production.rb. This enabled the system to find the CSS files that were apparently causing the 'nil'. The other change I tried was removing :cache => true from the stylesheets.
serve_static_assets
The problem was occurring because serve_static_assets was set to false
in environments/production.rb. Changing this enabled the system to find the CSS files that were the 'nil' it was trying to convert into a String. I also removed :cache => true
, and in combination, this solved the Heroku deployment problem.
这篇关于一个有趣的小500错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!