views:

195

answers:

1

I have created a rails application that has a simple RESTful json API. This has worked for a while, but now we have run into a problem. The javascript framework that makes requests adds a "Content-Type" header to all requests . . . including GET requests. It sets the header to "application/json" and causes the rails app to crash and burn with this error:

/!\ FAILSAFE /!\  2009-08-16 15:18:05 -0700
  Status: 500 Internal Server Error
  undefined method `split' for #<Mime::Type:0x00000100a85498>

I discovered long ago that setting this header for POST requests is necessary, but this seems to have really screwed up GET requests. I can replicate this error with ease using an app like "HTTP Client" - no header, successful GET, yes header, crash and burn!

Does anyone have any ideas what could be doing this/causing this and how I can accept this header on GET requests in my rails application?

Thanks ahead of time!

(Also, my setup: nginx/0.8.5 Phusion Passenger 2.2.4 ruby 1.9.1p129 (2009-05-12 revision 23412) [i386-darwin10.0.0b4] rails 2.3.2 )

+1  A: 

This appears to be a bug in Rails 2.3.2. There's a workaround posted here. Looks like it's fixed on edge Rails.

Dave Ray