I have a ruby on rails application which has two models - ltests and sub_tests.
An ltest has a 'has_many
' association with sub_tests.
In the show method for ltests is as follows.
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @ltest }
end
This renders the ltest object. However the sub_tests belonging to the ltest don't render.
How can I do this?
<ltest>
....
<sub_test>
...
</sub_test>
<sub_test>
...
</sub_test>
</ltest>
I tried rendering it using a view like this: <%= @ltest.to_xml %> <%= @ltest.sub_tests.to_xml %>
But this generates two xml documents rather than one with sub_tests embedded in ltests.
Any suggestions on how I can do this?