`render :nothing => true` whines about "missing template"

In FooController, I put method #bar whose only purpose is to run some
logic in the background and return a status 204 [1].

So in order to return only the 204 status code, I put at the end of
#bar:

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

But then when surfing to /foo/bar, I get an error about “missing
template bar.rhtml”. Is this a bug?

(The solution eventually was render :text => '', but it really seems
like a hack and that render => :nothing should have been the valid
solution)

-Chris

[1] HTTP/1.1: Status Code Definitions - “204 No
Content: The server has fulfilled the request but does not need to
return an entity-body”

On 1/3/07, Chris [email protected] wrote:

template bar.rhtml". Is this a bug?
It’s hard to know without seeing a code sample. Perhaps your render call
is
lurking within a conditional?

Note that in 1.2 you can do “head 204” or “head :no_content” when you
have
nothing to render and just want to return a status and optional headers.
The symbolic status code is translated to 204 No Content (likewise for
head
:forbidden, head :whatever_status_code, etc.)

jeremy

Jeremy K. wrote:

On 1/3/07, Chris [email protected] wrote:

template bar.rhtml". Is this a bug?
It’s hard to know without seeing a code sample. Perhaps your render call
is
lurking within a conditional?

I’ve checked again and the problem was with the way my testing browser
(FF 1.5.0.9 on Win32) interacted with the content-less response.

Probably because there was nothing to render, the browser simply
redisplayed the last rendered content, which happened to be the said
warning about missing template.

Rendering an empty string “fixed” this because the browser would then
display a blank page. My conusing was exacerbated by an additional
browser quirk: trying to refresh the page resulted in the browser
silently resending the last rendered request, i.e. the one which
emitted the “template missing” warning, instead of resending the request
that returned the blank 204.

Note that in 1.2 you can do “head 204” or “head :no_content” when you
have
nothing to render and just want to return a status and optional headers.
The symbolic status code is translated to 204 No Content (likewise for
head
:forbidden, head :whatever_status_code, etc.)

Thanks for all the information about 1.2. Not sure how much of an
improvement head is over render :nothing => true, which is nice
enough imho. However, being able to use symbolic status codes is
definitely a nifty feature!

-Chris

jeremy