railsのステータスコードの定義

REST本とか見てると、

status = '201 Created'

とかハードコーディングしてるけど、こみゅすけのコードとか見てるとそんなことしてなくて、

head :created

とか書いてあったのでrailsのコード内をgrepかけたら見つかった。メモっておく。

% ./script/console
Loading development environment (Rails 2.0.2)
>> p ActionController::StatusCodes::STATUS_CODES
{500=>"Internal Server Error", 423=>"Locked", 412=>"Precondition Failed", 401=>"Unauthorized", 302=>"Found", 203=>"Non-Authoritative Information", 407=>"Proxy Authentication Required", 501=>"Not Implemented", 424=>"Failed Dependency", 413=>"Request Entity Too Large", 402=>"Payment Required", 303=>"See Other", 226=>"IM Used", 204=>"No Content", 507=>"Insufficient Storage", 408=>"Request Timeout", 100=>"Continue", 502=>"Bad Gateway", 414=>"Request-URI Too Long", 403=>"Forbidden", 304=>"Not Modified", 205=>"Reset Content", 409=>"Conflict", 200=>"OK", 101=>"Switching Protocols", 503=>"Service Unavailable", 426=>"Upgrade Required", 415=>"Unsupported Media Type", 404=>"Not Found", 305=>"Use Proxy", 206=>"Partial Content", 410=>"Gone", 300=>"Multiple Choices", 201=>"Created", 102=>"Processing", 504=>"Gateway Timeout", 416=>"Requested Range Not Satisfiable", 405=>"Method Not Allowed", 207=>"Multi-Status", 510=>"Not Extended", 422=>"Unprocessable Entity", 411=>"Length Required", 400=>"Bad Request", 301=>"Moved Permanently", 202=>"Accepted", 505=>"HTTP Version Not Supported", 417=>"Expectation Failed", 406=>"Not Acceptable", 307=>"Temporary Redirect"}
=> nil
*>> p ActionController::StatusCodes::SYMBOL_TO_STATUS_CODE
{:temporary_redirect=>307, :requested_range_not_satisfiable=>416, :service_unavailable=>503, :im_used=>226, :internal_server_error=>500, :bad_request=>400, :gone=>410, :forbidden=>403, :not_implemented=>501, :method_not_allowed=>405, :upgrade_required=>426, :no_content=>204, :locked=>423, :moved_permanently=>301, :multiple_choices=>300, :not_modified=>304, :failed_dependency=>424, :multi_status=>207, :unsupported_media_type=>415, :insufficient_storage=>507, :precondition_failed=>412, :http_version_not_supported=>505, :created=>201, :reset_content=>205, :request_entity_too_large=>413, :not_extended=>510, :not_found=>404, :request_timeout=>408, :unauthorized=>401, :expectation_failed=>417, :processing=>102, :conflict=>409, :payment_required=>402, :unprocessable_entity=>422, :use_proxy=>305, :bad_gateway=>502, :non_authoritative_information=>203, :not_acceptable=>406, :gateway_timeout=>504, :switching_protocols=>101, :ok=>200, :see_other=>303, :found=>302, :accepted=>202, :length_required=>411, :partial_content=>206, :request_uri_too_long=>414, :continue=>100, :proxy_authentication_required=>407}
=> nil