i want to make render xml for an complex object ex make render :xml => posters poster = [name, post_id,created_at, ....] post = [title, body,created_at, ....] and i want the render *output* to be <posters> <poster> <name> name </name> <post> <title> title </title> <body> body </body> </post> ... ... </poster> ... ... </posters> thanks in advance M.SH -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/HjSKQMCHphcJ. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Tue, Apr 3, 2012 at 4:18 PM, M.SH <shehata.mohammed-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> i want to make render xml for an complex object > ex > make render :xml => posters > poster = [name, post_id,created_at, ....] > post = [title, body,created_at, ....] > > and i want the render output to be > > <posters> > <poster> > <name> > name > </name> > <post> > <title> > title > </title> > <body> > body > </body> > </post> > ... > ... > </poster> > ... > ... > </posters>You could have in your ../app/views/posters/ a file index.xml.builder which may be automatically called when the request needs to render XML. The file could start like this: xml.instruct! xml.posters do @posters.each do |poster| xml.poster(... ... end end end Check out Google for "xml builder Ruby" and this project from Jim Weirich. https://github.com/jimweirich/builder HTH, Peter -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.
Thank u very much , that is what i need :) On Tue, Apr 3, 2012 at 5:51 PM, Peter Vandenabeele <peter-jNuWw7i2w7syMbTcgqFhxg@public.gmane.org>wrote:> On Tue, Apr 3, 2012 at 4:18 PM, M.SH <shehata.mohammed-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > i want to make render xml for an complex object > > ex > > make render :xml => posters > > poster = [name, post_id,created_at, ....] > > post = [title, body,created_at, ....] > > > > and i want the render output to be > > > > <posters> > > <poster> > > <name> > > name > > </name> > > <post> > > <title> > > title > > </title> > > <body> > > body > > </body> > > </post> > > ... > > ... > > </poster> > > ... > > ... > > </posters> > > You could have in your ../app/views/posters/ > a file > > index.xml.builder > > which may be automatically called when the > request needs to render XML. The file > could start like this: > > xml.instruct! > xml.posters do > @posters.each do |poster| > xml.poster(... > ... > end > end > end > > Check out Google for "xml builder Ruby" > and this project from Jim Weirich. > > https://github.com/jimweirich/builder > > HTH, > > Peter > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- *------------------------- محمد شحاته 4th year** Computer and Systems **Department Alexandria University Egypt * -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.