Can't POST using Ruby 1.9.2 -- get Apache error

I have both ruby-1.8.7-p330 and ruby-1.9.2-p136 installed on my CentOS
server. I’m using Passenger (3.0.2) and Apache 2.2.3.

When using ruby-1.8.7, my app seems to be working fine.

When I change to ruby-1.9.2, GET requests seem to be fine, but POSTs
produce the following Apache error:

(104)Connection reset by peer: ap_content_length_filter:
apr_bucket_read() failed

And the following is in my production log:

Started POST “/login/verify_login” for etc…

TypeError (can’t convert nil into Integer):

From Googling, it looks like Apache is expecting Rails to handle the
request differently. I’ve seen this quote: “This works as designed. It
is the task of the cgi script to swallow the whole request body prior
to sending a response, whether it uses it for some purpose or not.”

Ok, so what do I change in Rails to make that happen?

Thanks!

More info: I reproduced this in development mode on my OS X machine,
again using Ruby 1.9.2. I now get a stack trace:

Error during failsafe response: ActionView::Template::Error
/.rvm/gems/ruby-1.9.2-p136/gems/activesupport-3.0.3/lib/active_support/whiny_nil.rb:48:in
method_missing' <path>/.rvm/gems/ruby-1.9.2-p136/gems/actionpack-3.0.3/lib/action_dispatch/http/parameters.rb:10:inparameters’
/.rvm/gems/ruby-1.9.2-p136/gems/actionpack-3.0.3/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb:3:in
/.rvm/gems/ruby-1.9.2-p136/gems/actionpack-3.0.3/lib/action_view/template.rb:135:in
block in render' <path>/.rvm/gems/ruby-1.9.2-p136/gems/activesupport-3.0.3/lib/active_support/notifications.rb:54:ininstrument’
/.rvm/gems/ruby-1.9.2-p136/gems/actionpack-3.0.3/lib/action_view/template.rb:127:in
render' <path>/.rvm/gems/ruby-1.9.2-p136/gems/actionpack-3.0.3/lib/action_view/render/rendering.rb:59:inblock in _render_template’
/.rvm/gems/ruby-1.9.2-p136/gems/activesupport-3.0.3/lib/active_support/notifications.rb:52:in
block in instrument' <path>/.rvm/gems/ruby-1.9.2-p136/gems/activesupport-3.0.3/lib/active_support/notifications/instrumenter.rb:21:ininstrument’
/.rvm/gems/ruby-1.9.2-p136/gems/activesupport-3.0.3/lib/active_support/notifications.rb:52:in
instrument' <path>/.rvm/gems/ruby-1.9.2-p136/gems/actionpack-3.0.3/lib/action_view/render/rendering.rb:56:in_render_template’
/.rvm/gems/ruby-1.9.2-p136/gems/actionpack-3.0.3/lib/action_view/render/rendering.rb:26:in
render' <path>/.rvm/gems/ruby-1.9.2-p136/gems/actionpack-3.0.3/lib/action_dispatch/middleware/show_exceptions.rb:88:inrescue_action_locally’
/.rvm/gems/ruby-1.9.2-p136/gems/actionpack-3.0.3/lib/action_dispatch/middleware/show_exceptions.rb:68:in
render_exception' <path>/.rvm/gems/ruby-1.9.2-p136/gems/actionpack-3.0.3/lib/action_dispatch/middleware/show_exceptions.rb:59:inrescue in call’
/.rvm/gems/ruby-1.9.2-p136/gems/actionpack-3.0.3/lib/action_dispatch/middleware/show_exceptions.rb:46:in
call' <path>/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.3/lib/rails/rack/logger.rb:13:incall’
/.rvm/gems/ruby-1.9.2-p136/gems/rack-1.2.1/lib/rack/runtime.rb:17:in
call' <path>/.rvm/gems/ruby-1.9.2-p136/gems/activesupport-3.0.3/lib/active_support/cache/strategy/local_cache.rb:72:incall’
/.rvm/gems/ruby-1.9.2-p136/gems/rack-1.2.1/lib/rack/lock.rb:11:in
block in call' <internal:prelude>:10:insynchronize’
/.rvm/gems/ruby-1.9.2-p136/gems/rack-1.2.1/lib/rack/lock.rb:11:in
call' <path>/.rvm/gems/ruby-1.9.2-p136/gems/actionpack-3.0.3/lib/action_dispatch/middleware/static.rb:30:incall’
/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.3/lib/rails/application.rb:168:in
call' <path>/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.3/lib/rails/application.rb:77:inmethod_missing’
/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.3/lib/rails/rack/log_tailer.rb:14:in
call' <path>/.rvm/gems/ruby-1.9.2-p136/gems/rack-1.2.1/lib/rack/content_length.rb:13:incall’
/.rvm/gems/ruby-1.9.2-p136/gems/rack-1.2.1/lib/rack/handler/webrick.rb:52:in
service' <path>/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/webrick/httpserver.rb:111:inservice’
/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/webrick/httpserver.rb:70:in
run' <path>/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/webrick/server.rb:183:inblock in start_thread’

Downgrading Ruby 1.9.2 to 1.8.7 fixed the issue for me.

I tried creating a new CRUD via “rails generate scaffold test
name:string” and even creating a new object there failed.

Instead of determining root cause, and since I don’t require 1.9.2, I
downgraded.

Since I am using RVM, I am able to downgrade to 1.8.7 on both my dev
machine and server in only 10 minutes. I had to change some gems
(e.g. ruby-debug19 to ruby-debug) in my Gemfile, then run “bundle
install” on my dev machine, check in the new gems into SVN, then “cap
deploy” to the server.

On the server, with RVM now set to 1.8.7 ( rvm install ruby-1.8.7; rvm
use --default ruby-1.8.7; rvm use default ) I installed the passenger
gem ( gem install passenger ) and recompiled the apache module
( passenger-install-apache2-module ) and then had to reset my
httpd.conf file with the new setting for passenger, as specified by
the output to the passenger-install-apache2-module.

I hope this helps.

I have the same exact issue.
Ruby 1.9.2p136
Passenger 3.0.2
Apache 2.2.14

I am currently looking for a solution.

I was about to try a blank test program, too. I haven’t had time to
let the server be down at the moment, so I backed down to 1.8.7 too. I
understand that 1.9.2 has much better performance, though, so I’d
really like to get it to work.

Can someone who is successfully using CentOS/Apache/Passenger/Ruby
1.9.2/Rails 3.0.3 please post the versions of CentOS, Apache, and
Passenger you are using? I can’t think of any other variable that
could be relevant, can you?

I had this problem too, which turned out to be quite interesting: the
combination of attachment_fu with Ruby 1.9.2 and Passenger 3 is not a
good one.

If your app runs on WEBrick (mine did) you can fix this by patching
attachment_fu.

In any case my fix might help you, because it was in a monkeypatch to
Tempfile.

For details please see
http://www.spacebabies.nl/2011/01/10/rails-on-ruby-1-9-2-every-post-failing/

Thanks for the tip. I do have attachment_fu in my app (although I plan
to switch to Paperclip). I removed it completely as a test (deleted
all the files under vendor/attachment_fu), then restarted httpd, but
it didn’t seem to help.