Sébastien Grosjean - ZenCocoon
2008-Jun-21 15:53 UTC
Rendering a partial as part of JSON object
Hi, I would like a controller to return a JSON object to my request but would need to render a partial as string, contained in this JSON object. Something like : # This doesn''t work as it makes more than one call to render in the same action render :json => {:number => 100, :string => render(:partial => ''string'')} I actually need such feature using ROR 1.2.6 Any idea how to achieve such result ? -- Sebastien Grosjean - ZenCocoon --~--~---------~--~----~------------~-------~--~----~ 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 21 Jun 2008, at 16:53, Sébastien Grosjean - ZenCocoon wrote:> > Hi, > > I would like a controller to return a JSON object to my request but > would need to render a partial as string, contained in this JSON > object. > > Something like : > > # This doesn''t work as it makes more than one call to render in the > same action > render :json => {:number => 100, :string => render(:partial => > ''string'')} > > I actually need such feature using ROR 1.2.6 >use render_to_string ? Fred> Any idea how to achieve such result ? > -- > Sebastien Grosjean - ZenCocoon > >--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Sébastien Grosjean - ZenCocoon
2008-Jun-21 17:16 UTC
Re: Rendering a partial as part of JSON object
Good point ;-) That works like a charm. Thanks a lot for your help, -- Sébastien Grosjean - ZenCocoon On Jun 21, 7:50 pm, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 21 Jun 2008, at 16:53, Sébastien Grosjean - ZenCocoon wrote: > > > > > > > Hi, > > > I would like a controller to return a JSON object to my request but > > would need to render a partial as string, contained in this JSON > > object. > > > Something like : > > > # This doesn''t work as it makes more than one call to render in the > > same action > > render :json => {:number => 100, :string => render(:partial => > > ''string'')} > > > I actually need such feature using ROR 1.2.6 > > use render_to_string ? > > Fred > > > Any idea how to achieve such result ? > > -- > > Sebastien Grosjean - ZenCocoon--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---