title: Rails 3 406 Not Acceptable error on attempting to use format.js, Can't change content-type either
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/1414446/weird-406-not-acceptable-error">Weird &ldquo;406 not acceptable&rdquo; error</a>  </p>
  </blockquote>
  
  
  
  <p>I've been stuck on this ALL DAY! In my rails 3 app I have a "new" page for Studies and an "edit" page. each of these pages has the same partials to add multiple Publications to a Study. In my edit page, updating the page via .js works fine, but in studies/new, when I create a new Publication I get a 406 Not Acceptable error. My Publications/create action looks like this:</p>
  
  <pre><code>def create
    @publication = Publication.new(params[:publication])
    @publication.display_number = @publication.get_display_number(session[:study_id])
    @publication.save
    @secondary_publications = Publication.find(:all, :order =&gt; 'display_number ASC', :conditions =&gt; {:is_primary =&gt; false, :study_id =&gt; session[:study_id]})  
  
   respond_to do |format|
    if @publication.save
          format.js {
              render :update do |page|
                  page.replace_html 'secondary_publication_table', :partial=&gt;'publications/table' 
              end
          }
    else
      format.html { render :action =&gt; "new" }
      format.xml  { render :xml =&gt; @publication.errors, :status =&gt; :unprocessable_entity }
    end
    end
    end
  </code></pre>
  
  <p>I've tried various ways I could find of setting the content-type (yet I don't have to do this on other pages...) such as</p>
  
  <pre><code>render :update, :content-type =&gt; "text/javascript" do |page|
  </code></pre>
  
  <p>but I can't get anything to change the content type from text/html when I call the action. Help?</p>
  
  <p>Thanks in advance!</p>
  
  <p>Edit: 
  the code submitted in the form looks like this:</p>
  
  <pre><code>&lt;%= nested_form_for @publication, :remote =&gt; true, :html=&gt;{:id=&gt;'secondary_pub_form'} do |f| %&gt;
  &lt;%= f.text_field :title %&gt;
  &lt;%= f.text_field :author, :size =&gt; 12 %&gt;
  &lt;%= f.text_field :country, :size =&gt; 10 %&gt;
  &lt;%= f.text_field :year, :size =&gt; 6 %&gt;
  </code></pre>
  
  <p>... etc...</p>
  
  <pre><code> &lt;% end %&gt;
  </code></pre>
  
  <p>the "nested_form_for" is a plugin that I'm using.. this setup has worked on other pages in the same way (using this plugin, loading a partial, etc)</p>