nfessel
#1
I have two models: ledger and label. A ledger can contain many
labels.
Here is the xml returned from http://localhost/ledgers/78.xml:
11
30.0
2007-10-22
2007-10-22
Deposit
78
Question:
How can I return the labels associated with the ledger? The xml should
look like this (notice the “labels” addition):
11
30.0
2007-10-22
2007-10-22
Deposit
78
Food
Music
nfessel
#2
I just figured it out.
Instead of this: format.xml { render :xml => @ledger.to_xml }
do this: format.xml { render :xml => @ledger.to_xml(:include =>
[ :labels ]) }
Works like a charm. 
nfessel
#3