Tony
Tony

Reputation: 10208

Rails error serving assets

I am migrating a big site from Rails 2 to Rails 3. When I try to get an asset I get the following error using Webrick:

Started GET "/assets/key.png" for 127.0.0.1 at 2013-03-20 11:00:06 -0300
Served asset /key.png - 200 OK (15ms)
[2013-03-20 11:00:08] ERROR NoMethodError: undefined method `each' for nil:NilClass
    /usr/local/rvm/gems/ruby-1.9.3-p327/gems/rack-1.4.5/lib/rack/handler/webrick.rb:71:in `service'
    /usr/local/rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service'
    /usr/local/rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'
    /usr/local/rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'

I have checked rack source code and the problem is in the following line of the file webrick.rb (body is nil):

body.each { |part|
        res.body << part
      }

Using Thin I get a similar error:

Started GET "/assets/key.png" for 127.0.0.1 at 2013-03-20 11:34:31 -0300
Served asset /key.png - 200 OK (33ms)
!! Rack application returned nil body. Probably you wanted it to be an empty string?
!! Unexpected error while processing request: undefined method `each' for nil:NilClass

And in the browser:

Error 324 (net::ERR_EMPTY_RESPONSE): The server closed the connection without sending any data.

I have been struggling with this error. Any help??

Upvotes: 0

Views: 727

Answers (2)

Kim Miller
Kim Miller

Reputation: 886

Indeed, it has to do with a missing memcache server. In my case I found that Heroku also publishes instructions for setting up a quick little memcached server for the purpose of duplicating your production env locally.

Upvotes: 0

Tony
Tony

Reputation: 10208

I found the problem.

It was something related to memcache. I dont have it installed.

I just commented the following line:

config.cache_store = :mem_cache_store

Upvotes: 2

Related Questions