RoR + AJAX + Safari = 500 Internal Server Error

Hi everyone,

I am running essentially the stock AJAX demo from here,

and it is working fine in every browser except one. Nope! Not that
one! It’s actually Safari which is giving me trouble. I know! Using a
link_to_remote call, for all other browsers places the sample text
into the div after the text, but in Safari, the server is apparently
returning a 500 Internal Server Error.

All I can think of is that Safari is creating a malformed request …
have a look:

http://www.mightywork.com/sandbox/toys/ajaxy

Can anyone help me to explain this most bizarre behavior? If I do get
my host involved (dreamhost), I would like to at lease know what to
ask them to fix.

Thanks in advance,

Whit

More information:

According to the log, a successful (Firefox) execution looks like
this:


Processing ToysController#say_when (for … at 2008-02-08 08:22:49)
[POST]
Session ID: …
Parameters: {“authenticity_token”=>“…”, “action”=>“say_when”,
“controller”=>“toys”}
Completed in 0.00408 (245 reqs/sec) | Rendering: 0.00008 (1%) | DB:
0.00000 (0%) | 200 OK [http://www.mightywork.com/sandbox/toys/
say_when]

But Safari’s request looks like this:


/!\ FAILSAFE /!\ Fri Feb 08 08:20:02 -0800 2008
Status: 500 Internal Server Error
can’t modify frozen string
/usr/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
request.rb:462:in gsub!' /usr/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/ request.rb:462:in clean_up_ajax_request_body!’
/usr/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
request.rb:380:in parse_formatted_request_parameters' /usr/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/ cgi_process.rb:78:in request_parameters’
/usr/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
request.rb:287:in parameters' /usr/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/ request.rb:22:in request_method’
/usr/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
request.rb:35:in method' /usr/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/ routing.rb:1483:in extract_request_environment’
/usr/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
routing.rb:1424:in recognize' /usr/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/ dispatcher.rb:170:in handle_request’
/usr/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
dispatcher.rb:115:in dispatch' /usr/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/ dispatcher.rb:126:in dispatch_cgi’
/usr/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
dispatcher.rb:9:in `dispatch’
dispatch.cgi:10

I am seeing this problem and I could reproduce this problem with FF,
Opera and Safari
from the Mac. It looks like a gem specific problem, Is there a patch
or workaround ?

-Arul

Interesting. I am seeing the same problem with my online deployment
on a FastCGI server. However, my local mongrel does not have the
problem at all. Very strange. This problem seems to be related to
any Ajax.request. My in place editors don’t work. Same for
autocompletion and all remote form tags.

My hypothesis is that this is an interaction between ROR 2.0.2 and
FastCGI.

I saw a trouble ticket on the rails trac that matches up:

http://dev.rubyonrails.org/ticket/10365

My initial gut feel on this has proved to be true. I migrated from
FastCGI to Mongrel and all of my Ajax problems magically disappeared.

I don’t know if it is a general FastCGI + Ajax problem, or if it is
specifically how my service provider has FastCGI tuned out, but the
exact same codebase works just fine on a Mongrel instance.

-J

I have the same problem… However, I cannot switch to Mongrel…

Nauhaie

Given that you seem to be alone in seeing this on all browsers, can I
ask more about your configuration that you were running your app on?
So far, everything else seems to indicate fcgi and not rails, and
seems to be unique to the rails + fcgi + apache2 + Safari combination.

On Feb 9, 1:08 pm, Arulchandran [email protected] wrote:

I am seeing this problem and I could reproduce this problem with FF,
Opera and Safari
from the Mac. It looks like a gem specific problem, Is there a patch
or workaround ?


_Deirdre http://deirdre.net/

rails 2.0.2 + fcgi 0.8.7 + apache2 + safari/FF/Opera combination was
working fine on my
local Leopard (Mac OSX 10.5) machine. When I deployed the code to
bluehost
(rails 2.0.2 + fcgi 0.8.7 + apache2), I was having problems in
remote_form_tag as
mentioned in the below ticket,

http://dev.rubyonrails.org/ticket/10365

I tried a workaround by changing the method as get for AjaxRequest and
it works for now.
But, still would like to find the root cause of this failure…

-Arul

Hi,

can you post your snippet?

thx