method

head

Importance_3
Ruby on Rails latest stable (v7.1.3.2) - 2 notes - Class: ActionController::Base

Method deprecated or moved

This method is deprecated or moved on the latest stable version. The last existing version (v2.3.8) is shown here.

These similar methods exist in v7.1.3.2:

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
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:

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