wycats / rack-offline

A Rack and Rails plugin for building offline web applications
MIT License
666 stars 82 forks source link

Does not work with unicorn, rails 3 and ruby 1.9 #5

Open bhavinkamani opened 13 years ago

bhavinkamani commented 13 years ago

When this plugin is used with unicorn and ruby 1.9. It breaks with following error

Read error: #<NoMethodError: undefined method `each' for #<String:0x00000100d88118>>
/Volumes/DATA/Bhavin/.rvm/gems/ruby-1.9.2-p0/gems/unicorn-3.0.0/lib/unicorn/http_response.rb:45:in `http_response_write'

While debugging, line no. 59 rack/offline.rb is breaking the code.

[200, {"Content-Type" => "text/cache-manifest"}, body.join("\n")]

line no. 45 in unicorn/http_response.rb looks like

body.each { |chunk| socket.write(chunk) }

It would have worked in ruby 1.8. But in 1.9 since String#each is deprecated, the code breaks.

Not sure what is the best solution. Should it be passed as an array? In that case newline will not be send to the browser.