Hey! I'm available for hire (and I appreciate tips)  



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

Was this useful to you? Share it!

Also, you can give me a tip or hire me.


Published

2009-12-7

Categories


Tags