NoMethodError: `bytesize' for 200:Fixnum (with Rails-3.0.3)

Thanks to Rails developer team.

I tried Rails3 along this guide:

Ruby on Rails Guides: Getting Started with Rails

and I met the problem described as following.
…Any ideas?

===========
Environment:

$ ruby -v
ruby 1.8.7 (2010-08-16 patchlevel 302) [i686-darwin9.8.0]
$ rails -v
Rails 3.0.3

===========
Steps for reproduce:

$ gem install rails
$ rails new testapp
$ cd testapp
$ ./script/rails generate controller Home index
$ ./script/rails server

then open http://localhost:3000/home/index

===========
Result(Problem):

Internal Server Error: undefined method `bytesize’ for 200:Fixnum

===========
Console output:

Started GET “/home/index” for 127.0.0.1 at Wed Dec 08 16:38:49 +0900
2010
Processing by HomeController#index as HTML
Rendered home/index.html.erb within layouts/application (2.3ms)
Completed 200 OK in 13ms (Views: 12.4ms | ActiveRecord: 0.0ms)

[2010-12-08 16:38:49] ERROR NoMethodError: undefined method bytesize' for 200:Fixnum /opt/local/lib/ruby/gems/1.8/gems/rack-1.2.1/lib/rack/ utils.rb:240:in bytesize’
/opt/local/lib/ruby/gems/1.8/gems/rack-1.2.1/lib/rack/
content_length.rb:22:in call' /opt/local/lib/ruby/gems/1.8/gems/actionpack-3.0.3/lib/ action_view/template.rb:255:in inject’
/opt/local/lib/ruby/gems/1.8/gems/rack-1.2.1/lib/rack/
content_length.rb:22:in each' /opt/local/lib/ruby/gems/1.8/gems/rack-1.2.1/lib/rack/ content_length.rb:22:in inject’
/opt/local/lib/ruby/gems/1.8/gems/rack-1.2.1/lib/rack/
content_length.rb:22:in call' /opt/local/lib/ruby/gems/1.8/gems/rack-1.2.1/lib/rack/handler/ webrick.rb:52:in service’
/opt/local/lib/ruby/1.8/webrick/httpserver.rb:104:in service' /opt/local/lib/ruby/1.8/webrick/httpserver.rb:65:in run’
/opt/local/lib/ruby/1.8/webrick/server.rb:173:in start_thread' /opt/local/lib/ruby/1.8/webrick/server.rb:162:in start’
/opt/local/lib/ruby/1.8/webrick/server.rb:162:in start_thread' /opt/local/lib/ruby/1.8/webrick/server.rb:95:in start’
/opt/local/lib/ruby/1.8/webrick/server.rb:92:in each' /opt/local/lib/ruby/1.8/webrick/server.rb:92:in start’
/opt/local/lib/ruby/1.8/webrick/server.rb:23:in start' /opt/local/lib/ruby/1.8/webrick/server.rb:82:in start’
/opt/local/lib/ruby/gems/1.8/gems/rack-1.2.1/lib/rack/handler/
webrick.rb:13:in run' /opt/local/lib/ruby/gems/1.8/gems/rack-1.2.1/lib/rack/ server.rb:218:in start’
/opt/local/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/rails/
commands/server.rb:65:in start' /opt/local/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/rails/ commands.rb:30 /opt/local/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/rails/ commands.rb:27:in tap’
/opt/local/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/rails/
commands.rb:27
./script/rails:6:in `require’
./script/rails:6

===========
Installed gems:

$ bundle install | sort
Your bundle is complete! Use bundle show [gemname] to see where a
bundled gem is installed.
Using abstract (1.0.0)
Using actionmailer (3.0.3)
Using actionpack (3.0.3)
Using activemodel (3.0.3)
Using activerecord (3.0.3)
Using activeresource (3.0.3)
Using activesupport (3.0.3)
Using arel (2.0.4)
Using builder (2.1.2)
Using bundler (1.0.5)
Using erubis (2.6.6)
Using i18n (0.4.2)
Using mail (2.2.10)
Using mime-types (1.16)
Using polyglot (0.3.1)
Using rack (1.2.1)
Using rack-mount (0.6.13)
Using rack-test (0.5.6)
Using rails (3.0.3)
Using railties (3.0.3)
Using rake (0.8.7)
Using sqlite3-ruby (1.2.4)
Using thor (0.14.6)
Using treetop (1.4.9)
Using tzinfo (0.3.23)

===========
Best Regards.

Kaoru Kobo
http://rubygems.org/profiles/kaorukobo

(tentative solution)

This problem seems to be related to rack(1.2.1).
I added this code to config/environment.rb, so tentatively, it works.

require “rack/content_length”
class << (Rack::ContentLength)
def new(app)
app
end
end