DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
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')
end




