Never been to DZone Snippets before?

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

About this user

Justin R http://blog.kineticweb.com/

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS 

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.

   1  
   2  desc 'Lists ActionController::StatusCodes::STATUS_CODES like routes'
   3  task :status_codes => :environment do
   4    puts "Status - Name"
   5    ActionController::StatusCodes::STATUS_CODES.to_a.sort.each { |code, message| 
   6      puts "#{code}    - #{message.gsub(/ /, "").underscore.to_sym}"
   7    } if ActionController::StatusCodes.constants.include?('STATUS_CODES')
   8  end
« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS