[ACCEPTED]-What causes a 422 Unprocessable Entity Error in Rails 3?-ruby-on-rails-3
Turns out that it was this line that was 2 causing this error:
@project = current_user.projects.build(params[:project])
I replaced the build
with 1 create
and all works now.
The answer here is, that any error in you 14 case will result in '422 Unprocessable Entity' when 13 you're responding in JSON format. The reason 12 is this line in your controller:
format.js { render :json => @project.errors, :layout => false, :status => :unprocessable_entity }
I.e. when 11 the object has errors and you are responding 10 in JSON format, you will always send the 9 422 status.
What you actually need is to 8 make a further investigation why would your 7 object have errors. And that could be anything. For 6 example: when not persisting the @project, it 5 may have caused a validation error, etc..
In 4 that case your question is irrelevant and 3 the accepted answer is misleading.
IMHO, you 2 should either change the question, or update 1 the answer.
More Related questions
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.