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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Feb 18, 2008 11:52 PM, MohsinHijazee <mohsinhijazee-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > 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, > Moshinreturn from the action early. return if performed? -- Rick Olson http://lighthouseapp.com http://weblog.techno-weenie.net http://mephistoblog.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Feb 19, 1:07 pm, "Rick Olson" <technowee...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Feb 18, 2008 11:52 PM, MohsinHijazee <mohsinhija...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > 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?> -- > Rick Olsonhttp://lighthouseapp.comhttp://weblog.techno-weenie.nethttp://mephistoblog.com--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 2/19/08, MohsinHijazee <mohsinhijazee-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Feb 19, 1:07 pm, "Rick Olson" <technowee...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > On Feb 18, 2008 11:52 PM, MohsinHijazee <mohsinhija...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > 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. -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---