title: Rails respond_with working incorrectly with json
body: <p>I am trying to update a record remotely (via ajax), and get a response which includes the serialized record, but I am continually getting xhr.responseText = {} . I would like to receive a serialized version of the updated record.</p>
  
  <p>Here is my view form...</p>
  
  <pre><code>=semantic_form_for theme, :html =&gt; {'data-type' =&gt; 'json', :id =&gt; :theme_display_type_form, :remote =&gt; true} do |form|
      -form.inputs do
          =form.input :display_type
  </code></pre>
  
  <p>The controller which processes...</p>
  
  <pre><code>respond_to :html, :json
  
  ... other actions...
  
  def update
     flash[:success] = "Theme was successfully updated" if theme.update_attributes params[:theme]
     respond_with(theme)
  end
  </code></pre>
  
  <p>and then the response is caught by the rails.js ajax:success event</p>
  
  <pre><code>$('#theme_display_type_form').bind('ajax:success', function(evt, data, status, xhr){
     var responseObject = $.parseJSON(xhr.responseText);
     alert(xhr.responseText); // = {}
     alert(responseObject); // = null
  });
  </code></pre>
  
  <p>I must be missing something. Can anyone inform me of what I'm doing wrong?</p>
  
  <hr>
  
  <p><strong>EDIT</strong></p>
  
  <p>It looks like I may be having an issue with '<strong>respond_with</strong>' as using the old respond_to method in my controller works properly...</p>
  
  <pre><code>def update
     flash[:success] = "Theme was successfully updated" if theme.update_attributes params[:theme]
     respond_to do |format|
        format.json { render :json =&gt; theme }
     end
  end
  </code></pre>
  
  <p>Anyone have any ideas why respond_with not working properly?</p>
  
  <hr>
  
  <p><strong>ANSWER</strong></p>
  
  <p>as per the lighthouse posting on <a href="https://rails.lighthouseapp.com/projects/8994/tickets/5199-respond_with-returns-on-put-and-delete-verb" rel="nofollow">https://rails.lighthouseapp.com/projects/8994/tickets/5199-respond_with-returns-on-put-and-delete-verb</a></p>
  
  <p>it is normal that an UPDATE will return no object, since you already have the object in your possession.. </p>