Needed proper structure for a controller null response

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?

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs