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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With