💎 Ruby on Rails
Beginner
What is the difference between GET and POST in Rails forms?
Answer
In HTML, forms submit data via GET (appends data to URL as query string — visible, bookmarkable, idempotent — used for search forms) or POST (sends data in request body — not visible in URL — used for creating/modifying data). Since HTML only supports GET and POST natively, Rails uses a hidden _method field and the rack-methodoverride middleware to simulate PATCH, PUT, DELETE for RESTful updates and deletes. Rails form helpers (form_with) automatically include CSRF tokens and set the correct HTTP method.