Rails: Post 422 (Unprocessable Entity) in Rails? Due to the Routes or the Controller

Rails: POST 422 (Unprocessable Entity) in Rails? Due to the routes or the controller?

I got it working!

I added a...

skip_before_action :verify_authenticity_token

to the controller.

The issue was found when checking out the logs and seeing that the CSRF token could not be verified.

422 Unprocessable Entity in rails

Adding this line at the start of upload_main_file function fixed the problem

skip_before_action :verify_authenticity_token

What causes a 422 Unprocessable Entity Error in Rails 3?

Turns out that it was this line that was causing this error:

@project = current_user.projects.build(params[:project])

I replaced the build with create and all works now.

Rails best_in_place Unprocessable Entity

I figured out what the problem was and how to fix it. We use an option to Save or Save As when editing materials. In the controller we therefore check for the params[:commit].

By editing the url I was able to send in the params[:commit] with the update with best_in_place. Here is how the best_in_place code ended up like:

<%= best_in_place @material, :name, as: :input, url: material_path(@material, commit: "Save") %>


Related Topics



Leave a reply



Submit