简体   繁体   中英

An interesting little 500 error

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.

They're not related. The error locally is because you're using the command incorrectly. Do:

rails server -e production

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.

Well, I don't know if these 2 issues related...

First, would you please provide the code of your welcome controller? let's see what's going on there.

Second, your command not correct, please run: rails server -e production

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM