Possible Duplicate:
Weird “406 not acceptable” error
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:
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 => 'display_number ASC', :conditions => {:is_primary => false, :study_id => session[:study_id]})
respond_to do |format|
if @publication.save
format.js {
render :update do |page|
page.replace_html 'secondary_publication_table', :partial=>'publications/table'
end
}
else
format.html { render :action => "new" }
format.xml { render :xml => @publication.errors, :status => :unprocessable_entity }
end
end
end
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
render :update, :content-type => "text/javascript" do |page|
but I can't get anything to change the content type from text/html when I call the action. Help?
Thanks in advance!
Edit: the code submitted in the form looks like this:
<%= nested_form_for @publication, :remote => true, :html=>{:id=>'secondary_pub_form'} do |f| %>
<%= f.text_field :title %>
<%= f.text_field :author, :size => 12 %>
<%= f.text_field :country, :size => 10 %>
<%= f.text_field :year, :size => 6 %>
... etc...
<% end %>
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)