Request-URI Too big mistake - get rid of GET?

I have a form on my website where users can send response text that will be checked by the controller.
It uses the standard GET form:

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

But I recently got the following error with a long answer:

Request-URI is too large
WEBrick :: HTTPStatus :: RequestURITooLarge

Do I have to change the form to POST to fix the error? Will it require any other changes?

+4
source share
1 answer

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

This will require changing the form tag:

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

Depending on the current routing, a route update may also be required: (since when using resources , POST requests are routed by default to the create method in your controller)

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

+9
source

Source: https://habr.com/ru/post/1489017/


All Articles