0

これをcurlに渡したい:

<invoice>
.....
<invoice-details>
<invoice-detail>
....
</invoice-detail>
<invoice-detail>
....
</invoice-detail>
</invoice_details>
</invoice>

ちなみに、関連する2つのモデルinvoiceとinvoice_detailがあります。請求書をすべてのinvoice_detailsに渡すための主キーがあるので、IDを付けることができます。たとえば、主キーが 200 の場合、その請求書の下のすべての詳細にも 200 の外部キーが必要です。どうすればこれを達成できるでしょうか?どうもありがとう。

4

1 に答える 1

0

このアクションの xml ビューを作成します。あなたのコントローラーには、次の Respond_to ブロックがあると思います。
respond_to do |format|
format.html
format.xml {render :xml => @invoice}

xml ビューの作成の詳細については、xml ビルダーまたはこのSO の質問を確認してください。

curl を介して渡すには、URL で .xml を要求します。次に例を示します。

curl "http://yourapp.com/invoices/2/show.xml"

于 2012-05-25T10:50:16.337 に答える