[Rails] Correspondence table of HTTP status code symbols and their meanings (for myself)

I check it every time I forget it, so I summarized it for myself.

Rough meaning of each series

100 ~ Means the continuation of requests from the browser. 200 ~ Means that the browser request was successful on the server. 300 ~ Means redirect. 400 ~ It means that there is an error on the client side and the request failed. 500 ~ It means that there is an error on the server side and the request failed.

Status Code Meaning and Rails Symbols

Only the ones I use often Difference between put and patch put method replaces rather than updates The patch method updates / modifies / modifies existing resources For more information https://qiita.com/murata0705/items/52538c08778c39a91ec2

Code number symbol Remarks meaning
200 :ok Frequently returned when getting The web page or resource is working as expected.
201 :created create,Returns this when put etc. Accepted the request and created a new resource.
202 :accepted The situation where the server is accepting and processing browser requests
204 :no_content delete,Returns this when patch etc. When the request was processed successfully, but there is no content to return
304 :not_modified When you want to use the cache Means that the requested resource has not changed since it was last accessed.
400 :bad_request The shape of the request body is strange, validation error, etc. In case of incorrect syntax, invalid request message framing, or incorrect request routing
401 :unauthorized I don't have permission If you need an Authorization header.
404 :not_found The resource represented by the URL does not exist.
409 :conflict When trying to create something that has already been created. The request cannot be completed because it conflicts with the current resource.
422 :unprocessable_entity When you want to get a more detailed validation error. It means that a normal request came but could not be processed.

reference

https://qiita.com/terufumi1122/items/997e24dde87f807e3944

https://qiita.com/uenosy/items/ba9dbc70781bddc4a491

https://qiita.com/nesheep5/items/6da796f6ac628c430c36

Recommended Posts

[Rails] Correspondence table of HTTP status code symbols and their meanings (for myself)
Summary of rails validation (for myself)
Table of contents Code refactoring and related articles
Various correspondence table of Spring Framework and Spring Boot