Ruby on Rails - how to render as xml models with has_many associations -
Has_many 'Association with sub_tests is thus in the show method for the list.
response_to do | Format | Format.html # show.html.erb format.xml {Render: xml = & gt; @ltest} end
Although it provides the ltest object, subtitles related to ltest do not render.
How can I do this?
& lt; Ltest & gt; .... & lt; Sub_test & gt; ... & lt; / Sub_test & gt; & Lt; Sub_test & gt; ... & lt; / Sub_test & gt; & Lt; / Ltest & gt;
I tried to present it using a sequence like this:
But it creates two xml documents instead of subtitests with one instead of one ltests Embedded in
Any suggestions on how I can do this?
You do not have to use builder or ARB for this. You can get whatever you want in the controller (at least I run the train 2.3.4). Like:
format.xml {render: xml = & gt; @ Ltest.to_xml (: included = & gt;: sub_tests)}
Comments
Post a Comment