Welcome Guest | Login

Rails 2.0.2 Ajax request slap-down

When my newly deployed Ajaxified rails 2.0.2 app receives an Ajax request from my Safari browser, the following error occurs:

/!\ FAILSAFE /!\  Fri Feb 15 11:59:11 -0600 2008
 Status: 500 Internal Server Error
 can't modify frozen string
   /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/request.rb:462:in `gsub!'
   /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/request.rb:462:in `clean_up_ajax_request_body!'
   /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/request.rb:380:in `parse_formatted_request_parameters'
   /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/cgi_process.rb:78:in `request_parameters'
   /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/request.rb:287:in `parameters'
   /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/request.rb:22:in `request_method'
   /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/request.rb:35:in `method'
   /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/routing.rb:1483:in `extract_request_environment'
   /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/routing.rb:1424:in `recognize'
   /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:170:in `handle_request'
   /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:115:in `dispatch'
   /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:126:in `dispatch_cgi'
   /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:9:in `dispatch'
   dispatch.cgi:10
Appears that the Ajax request has a problem?  Same application works just fine on my local Mongrel deployment

2008-02-15 12:00 PM

-- Bridger
Does it work in other browsers online ?  What is the view code and the application code that receives the AJAX call?  Is it FastCGI or Mongrel online?

2008-02-15 06:52 PM

I don't have a windows machine handy, and Firefox seems to have problems submitting forms (for some reason it is posting with no form arguments).  Shiira has the same problem as Safari.

This is FastCGI.

This applies to every case where I am using a remote form or ajax request.  Here's an example:

<% form_remote_tag :html => {:id => 'note_form'}, :url =>guest_guest_notes_path(@guest) do %>

<%= text_area_tag :content, nil, {:rows=>"4",
 :onbeforepaste => "FormHelper.stretchyTextArea(this,200,450)",
 :onkeypress => "FormHelper.stretchyTextArea(this,200,450)",
 :oninput => "FormHelper.stretchyTextArea(this,200,450)",
 :tabIndex => "1"}
%>
<%= hidden_field(:guest, :id) %>

<p><label>What kind of note? </label><%= select :note, :type, @note_types, {}, {:tabIndex => "2", :default => @note_types[0]}%></p>
<p><label>When did this activity happen? </label><%= calendar_date_select_tag "date", Time.now.strftime("%B %d, %Y") %></p>
<%= submit_tag "Add this note"%>

<% end %>
handled by a guest_notes create...

  def create

   @content = params[:content]
   @guest_id = params[:guest_id]
   @guest = Guest.find(@guest_id)
   @guest_note = GuestNote.for_guest_by_author(@guest,@author)

   @guest_note.content = @content
   
   respond_to do |format|
     if @guest_note.save
       flash[:notice] = 'GuestNote was successfully created.'
       format.html { redirect_to guest_guest_notes_path(@guest) }
       format.xml  { head :created, :location =>guest_guest_notes_path(@guest) }
       format.js {} # Ajax pass thru
     else
       flash[:notice] = 'Unable to create note.'
       format.html { render :action => "new" }
       format.xml  { render :xml => @guest_note.errors.to_xml }
     end
   end      
 end
This controller code never gets executed because the app bombs out unrolling the ajax request.

2008-02-19 09:01 AM

-- Bridger
Its very possible this is a FastCGI and REST issue.  I would suggest asking support to bump you up on Mongrel for free to check it out (mention this thread).  Go ahead and follow the mongrel tutorial and fire up a Mongrel on port 4729 and contact them as the tutorial mentions.

2008-02-19 12:36 PM

Excellent.  I'll try this out today.

2008-02-22 08:27 AM

-- Bridger
It looks as though moving to Mongrel got rid of all the ajax issues except one.  The last problem may actually be a coding problem, so I'll look into that.  It looks like FastCGI+Safari+Ajax = BOOM and FastCGI+Firefox+HTTP:POST = BOOM.

Very strange.  Are other folks experiencing FastCGI bustedness or is everyone in the Mongrel club?

2008-02-25 11:27 AM

-- Bridger
Yeah - we've had a lot of FastCGI bustedness reports and are working on fixes.  Until then we're bumping all who need it to mongrel.  

2008-02-25 12:00 PM

Great.  Well, it seems that I'm off and running now.  Thanks!

2008-02-25 12:04 PM

-- Bridger

Hello Guest! In order to post you must be an active client with us, please log in or sign up.