You know what's "Not Acceptable"? Not having a more meaningful error message!

One probable cause for a 406 error is that you're requesting an invalid format.

For example, let's say you're requesting application/json from /model.json and you've got a block of code like:
respond_to |format|
if @model.save
format.html
format.xml { render :xml => @model }
else
format.html
format.xml { render :xml => @model.errors }
end
end

That's a problem.

And you're not getting a response back telling you what the error is because the error is the server notifying your client that it can't accept the response...... infinite loop.... anyway, you've forgotten to add in something like this:
    format.json { render :json => @model.errors }

Next you'll probably get a 422, but that just means something is wrong with the data saving itself. At least in that case you'll have a decent error message to look at.

|8^D

By AJ ONeal

If you loved this and want more like it, sign up!


Did I make your day?
Buy me a coffeeBuy me a coffee  

(you can learn about the bigger picture I'm working towards on my patreon page )