Tackling Double Rendering

Hi!
I am calling a method like this:

def index()

  json = super.get_customers()

  respond_to do |format|
     format.json { render :json => json and return }
  end

end

But the problem is that the underlying method get_customers might have
called a render :text => ‘Invalide Parameters or whatever’ earlier and
the later code under the respond_to gives double render error. Is
there any way to discard the results of the previous rendering and
start at a clean slate?

Regards,
Moshin

On Feb 18, 2008 11:52 PM, MohsinHijazee [email protected] wrote:

  end

end

But the problem is that the underlying method get_customers might have
called a render :text => ‘Invalide Parameters or whatever’ earlier and
the later code under the respond_to gives double render error. Is
there any way to discard the results of the previous rendering and
start at a clean slate?

Regards,
Moshin

return from the action early.

return if performed?


Rick O.
http://lighthouseapp.com
http://weblog.techno-weenie.net
http://mephistoblog.com

On Feb 19, 1:07 pm, “Rick O.” [email protected] wrote:

there any way to discard the results of the previous rendering and
start at a clean slate?

Regards,
Moshin

return from the action early.

return if performed?

And what if we need to render in any case? By wiping out the previous
renders?

On 2/19/08, MohsinHijazee [email protected] wrote:

     format.json { render :json => json and return }

Moshin

return from the action early.

return if performed?

And what if we need to render in any case? By wiping out the previous
renders?

Well you should redesign so as not to have to do that, but there is an
undocumented method erase_render_results in ActionController::Base

By the way that super.get_customers is suspicious. Ruby doesn’t let
you call super with a message name other than the current one.


Rick DeNatale

My blog on Ruby
http://talklikeaduck.denhaven2.com/