v2.3.2 - Show latest stable - 2 notes - Class: ActionController::Base
head(*args) protected

Return a response that has no content (merely headers). The options argument is interpreted to be a hash of header names and values. This allows you to easily return a response that consists only of significant headers:

  head :created, :location => person_path(@person)

It can also be used to return exceptional conditions:

  return head(:method_not_allowed) unless request.post?
  return head(:bad_request) unless valid_request?
Show source
Register or log in to add new notes.
July 7, 2008
5 thanks

List of statuses

You can view a full list of statuses at http://dev.rubyonrails.org/browser/trunk/actionpack/lib/action_controller/status_codes.rb.

head can be called with a symbol or a status code:

Using head with a symbol

head :length_required # 411 Length Required
head :ok              # 200 OK

Using head with a status code

head 404              # 404 Not Found
November 26, 2013
0 thanks

Updated list of statuses

The list of supported statuses is now in the layout & rendering rails guide: