Such as
200 => Found
403 => Not authorized
404 => Not found
I'm guessing Rails 3 already has this functionality as you can pass a hash to render :status => :not_found
, I just can't find the method to do it the other way. If not does anyone know of a gem which can do this?
irb(main):001:0> Rack::Utils::HTTP_STATUS_CODES[200]
=> "OK"
irb(main):002:0> Rack::Utils::HTTP_STATUS_CODES[403]
=> "Forbidden"
irb(main):003:0> Rack::Utils::HTTP_STATUS_CODES[404]
=> "Not Found"
or
irb(main):004:0> Rack::Utils.status_code(:ok)
=> 200
irb(main):005:0> Rack::Utils.status_code(:forbidden)
=> 403
irb(main):006:0> Rack::Utils.status_code(:not_found)
=> 404
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