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

return from the action early.

return if performed?

> 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

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.