On Tue, Apr 3, 2012 at 4:18 PM, M.SH <[email protected]> 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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to