|HTTP status code symbols for Rails|
|Thanks to Cody Fauser for this list of HTTP responce codes and their Ruby on Rails symbol mappings.|
|Status Code Symbol|
|4xx Client Error|
|5xx Server Error|
No 3rd party code needed:
Missing an important one : https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/418
@danielricecodes already written in official Rails Guides
Documentation for generic status types are so hard to find.
Just leaving this here for future reference:
In rspec: https://relishapp.com/rspec/rspec-rails/docs/matchers/have-http-status-matcher
@alexsmartens : It looks like no, it's not. Or at least it's not easy.
A few days ago I was trying to achieve exactly that. I had a nice idea, that you could pass a string for example in
(I wanted the status text to be dynamic, so that each render might set it differently - for example providing translated statuses, in line with what all the relevant RFCs say. Merely adding another entry to the Rack::Utils::HTTP_STATUS_CODES was not good enough for me. But even that would not work.)
With these changes to the
plus some changes to
But then I got into Puma, where the status was again converted to integer, and the status text was being taken again from a hardcoded list of texts (same form as in rack/utils, but it's a separate code). At that point I gave up.
The coding itself looks trivial. The real problem lies in testing for backwards compatibility, and - this is the most terrifying part! - talking to various groups of people to accept these changes into their projects.
If you feel brave enough, you may try to work on that.