method

head

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?
  render

2Notes

List of statuses

larssg · Jul 7, 20085 thanks

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

Updated list of statuses

mattsa · Nov 26, 2013

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

http://guides.rubyonrails.org/layouts_and_rendering.html#the-status-option