# Needed proper structure for a controller null response

**URL:** <https://www.ruby-forum.com/t/needed-proper-structure-for-a-controller-null-response/173076>\
**Category:** Rails\
**Created:** [August 1, 2009, 8:01pm UTC](https://www.ruby-forum.com/t/needed-proper-structure-for-a-controller-null-response/173076 "2009-08-01T20:01:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![explainer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/bbce88/32.png) [@explainer](https://www.ruby-forum.com/u/explainer)\
**Post date:** [August 1, 2009, 8:01pm UTC](https://www.ruby-forum.com/t/needed-proper-structure-for-a-controller-null-response/173076/1 "2009-08-01T20:01:11Z")

</div>

I have a situation where a part of a page is under the control of  
periodically\_call\_remote() js helper. In response, the controller  
answers with a render(:partial …). When the controller knows that  
nothing in the display has changed, I wish to respond with the  
equivalent of a ‘200 OK’ response. How can I code that in the  
controller?

---

<div class="post-metadata">

**Author:** ![explainer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/bbce88/32.png) [@explainer](https://www.ruby-forum.com/u/explainer)\
**Post date:** [August 1, 2009, 9:16pm UTC](https://www.ruby-forum.com/t/needed-proper-structure-for-a-controller-null-response/173076/2 "2009-08-01T21:16:06Z")

</div>

Hi,

On Sat, 2009-08-01 at 10:59 -0700, explainer wrote:

> I have a situation where a part of a page is under the control of  
> periodically\_call\_remote() js helper. In response, the controller  
> answers with a render(:partial …).

I’m not sure I understand your explanation.

You say you’re using periodically\_call\_remote which would lead me to  
expect that in your controller (assuming that’s where you’re  
responding), you’d be using

render :update do |page|  
page.replace\_html (or some variation) …  
end

But you say your controller 'answers with a render(:partial …)

I’ll take a stab below, but if that doesn’t get it please post relevant  
code.

> When the controller knows that  
> nothing in the display has changed, I wish to respond with the  
> equivalent of a ‘200 OK’ response. How can I code that in the  
> controller?

If you’re returning html, you can just use head (in  
ActionController::Base)

return head(:success)  
render

I’m not sure how to return just a header with js cause I’ve never needed  
to do it, but the first thing I’d probably try would be:

render :js =\> ‘’

or

render :js =\> ‘’, :status =\> :success

If for whatever reason those didn’t work, I’d probably create an empty  
element on the page and…

render :update do |page|  
page.replace\_html ‘empty\_element’, ‘’  
end

HTH,  
Bill
