Ruby on Rails Tuesday, April 3, 2012

Thank u very much , that is what i need :)

On Tue, Apr 3, 2012 at 5:51 PM, Peter Vandenabeele <peter@vandenabeele.com> wrote:
On Tue, Apr 3, 2012 at 4:18 PM, M.SH <shehata.mohammed@gmail.com> 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@googlegroups.com.
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.




--
-------------------------
محمد شحاته
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@googlegroups.com.
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.

No comments:

Post a Comment