質問

I have a form on my site where users can submit answer text to be checked by the controller.
It uses a standard GET form:

<%= form_tag('/submit', method: "get", remote: true) do %>

But I recently got the following error on long answer:

Request-URI Too Large
WEBrick::HTTPStatus::RequestURITooLarge

Should I change the form to POST to fix the error? Would this require any other changes?

役に立ちましたか?

解決

It depends on the browser / web server, but the average limit for a URL is 2000 characters. So yes, if you are hitting the limit change it to POST.

This will require changing the form tag:

<%= form_tag('/submit', method: "post", remote: true) do %>

Depending on your current routing, it might also require updating your route: ( since when using resources POST requests by default are routed to the create method in your controller )

match '/submit', to: 'submit#index', via: :post

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top