Over a million developers have joined DZone.

List HTTP Status Codes In Rails

If you follow the Rails way of RESTful controllers you should familiarize yourself with all the return status codes available in the HTTP protocol.

The following is a handy list, like "rake routes", for listing out all the HTTP codes that you can return in your controller logic.

desc 'Lists ActionController::StatusCodes::STATUS_CODES like routes'
task :status_codes => :environment do
  puts "Status - Name"
  ActionController::StatusCodes::STATUS_CODES.to_a.sort.each { |code, message| 
    puts "#{code}    - #{message.gsub(/ /, "").underscore.to_sym}"
  } if ActionController::StatusCodes.constants.include?('STATUS_CODES')

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}