Lorsque j'essaie de lancer cette action via Javascript, j'obtiens une erreur 406 Not Acceptable
:
def show
@annotation = Annotation.find_by_id(params[:id])
respond_to do |format|
format.html {
if @annotation.blank?
redirect_to root_path
else
redirect_to inline_annotation_path(@annotation)
end
}
format.js {
if params[:format] == "raw"
render :text => @annotation.body.to_s
else
render :text => @annotation.body.to_html
end
}
end
end
Ceci est de jQuery, mais je fais le bon avant d'envoyer des choses:
$.ajaxSetup({
beforeSend: function(xhr) {
xhr.setRequestHeader("Accept", "text/javascript");
},
cache: false
});
Voici les en-têtes de ma demande:
Host localhost:3000
User-Agent Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3
Accept text/javascript
Accept-Language en-us,en;q=0.5
Accept-Encoding gzip,deflate
Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive 300
Connection keep-alive
X-Requested-With XMLHttpRequest
Content-Type application/x-www-form-urlencoded