我刚刚尝试部署到Heroku并遇到500服务器错误。
heroku日志:
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'
然后我尝试以生产模式启动本地服务器:
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>'
这些问题似乎高度相关 - 你知道这里可能出现什么问题吗?
非常感谢!
欢迎控制器#index
def index
render :layout => "index"
end
请告诉我是否可以提供更多信息。
感谢你们的回答。发生此问题是因为在environment / production.rb中将serve_static_assets设置为false。这使系统能够找到显然导致'nil'的CSS文件。我尝试的另一个更改是删除:cache =&gt;样式表中的确如此。
答案 0 :(得分:4)
他们没有关系。本地错误是因为您错误地使用了该命令。做:
rails server -e production
答案 1 :(得分:1)
好吧,我不知道这两个问题是否有关......
首先,请您提供欢迎控制器的代码?让我们看看那里发生了什么。
其次,你的命令不正确,请运行: rails server -e production
答案 2 :(得分:1)
问题出现了,因为在environment / production.rb中,serve_static_assets设置为false
。更改此设置使系统能够找到尝试转换为String的'nil'的CSS文件。我还删除了:cache => true
,并结合使用,解决了Heroku部署问题。