Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

render :nothing => true should set HTTP status 204

#3499

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.

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

State: invalid
Milestone: none
Assigned to: nobody
Importance: none

Activity

  1. Mike Riley
    Mike Riley
    • 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

    July 29th, 2010 @ 03:44 PM