views:

147

answers:

2

In most frameworks, sending a redirect means setting the HTTP headers and exiting without sending any HTML data back to the browser. However, using Firebug I see that Rails is not following this convention:

def update
    @phone_number = PhoneNumber.find(params[:id])
    if @phone_number.update_attributes(params[:phone_number])
      flash[:notice] = "Successfully updated phone number."
      redirect_to @phone_number
    else
      render :action => 'edit'
    end
end

In response, the headers have:

Connection  close
Date        Tue, 27 Oct 2009 06:17:00 GMT
X-Runtime    28
Location      http://localhost:3000/phone_numbers/1999521184

and it also has the results from the show action, twice

Any ideas why?

+1  A: 

Interesting. It appears that firebug is lying to me. Using WireShark, I confirmed that it is in fact not sending the page data, just the redirect and a basic "You are being redirected" message. Looks like a bug with firebug.

DGM
+1  A: 

Could be a bug with Firebug. Another thing to try this:

redirect_to @phone_number and return
PatrickTulskie