Weird “406 not acceptable” error

I cracked the case!

I was sending a format parameter with my get request in order to tell the server to send me markdown instead of HTML. Here’s my Javascript:

$.get("/annotations/" + annotation_id, {format: 'raw'}, function(data) {
});

and then I was looking for this parameter in the format.js block:

   format.js {
     if params[:format] == "raw"
       render :text => @annotation.body.to_s
     else
       render :text => @annotation.body.to_html
     end
   }

but apparently a format parameter confuses the respond_to block. I changed it from {format: 'raw'} to {markdown: 'true'} and it works.

I guess this is a bug in Rails?

Leave a Comment