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|
format.xml { render :xml => @model }
format.xml { render :xml => @model.errors }

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.


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 )



Buy me a coffeeBuy me a coffee

  73% of Goal Reached

Want more like this?