This project is archived and is in readonly mode.

#3499 ✓invalid
Andreas Mayer

render :nothing => true should set HTTP status 204

Reported by Andreas Mayer | November 20th, 2009 @ 08:23 PM

I often see people using

render :nothing => true, :status => 204

in their controllers to set the correct HTTP status for "nothing": 204 No Content (see RFC 2616 10.2.5). But why set it manually? I think render :nothing implies return status 204 and so it should be set automatically.

Comments and changes to this ticket

  • Mike Riley

    Mike Riley July 29th, 2010 @ 03:44 PM

    • State changed from “new” to “invalid”
    • Importance changed from “” to “”

    Hello Andreas,

    I am going to mark this as invalid as this is not a bug with Rails. I did, however, want to give you information on this so it can help you. Based on this Ruby on Rails guide (http://guides.rubyonrails.org/layouts_and_rendering.html) you shouldn't be using render :nothing, but instead using the head method. It states:

    The head method exists to let you send back responses to the browser that have only headers. It provides a more obvious alternative to calling render :nothing. The head method takes one response, which is interpreted as a hash of header names and values. For example, you can return only an error header:
    head :bad_request

    Hope this helps.
    Mike Riley

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Pages