rendering xml using curl in rails models

Disch1988

New Member
I'm using rails 2.3.5, rubygems 1.8.24, ruby 1.9.3 and mac os xi have two models: Invoice and*InvoiceDetail*invoice has_many invoiceDetail and invoiceDetail belongs_to invoiceI want to post this xml file so that the fields for invoice and invoice_detail are filled:\[code\]<?xml version="1.0" encoding="UTF-8"?><invoice>.....<invoice-detail>..... </invoice-detail></invoice>\[/code\]the fields for invoice are filled, but for the invoice_detail, it's empty.I used this curl command: curl -v -H "Content-Type: application/xmlet=utf-8" --data-ascii @invoice.xml.erb localhost:3000/invoice.xmlAny help would be greatly appreciated. Thank you!EDIT: CONTROLLER\[code\]class InvoiceController < ApplicationControllerdef index@invoice = Invoice.find(:first)respond_to do |format| format.html # index.html.erb format.xml { render :xml => @invoice.to_xml(:include => :invoice_detail) } endenddef create @invoices = Invoice.new respond_to do |format| if @invoices.update_attributes( params[:invoice] ) format.xml { render :xml => { :id => @invoices.id }.to_xml(:include => :invoice_detail), :status => :created } format.json { render :json => { :id => @invoices.id }.to_xml(:include => :invoice_detail), :status => :created } else format.xml { render :xml => @invoices.errors.to_xml(:include => :invoice_detail), :status => :unprocessable_entity } format.json { render :json => @invoices.errors.to_xml(:include => :invoice_detail), :status => :unprocessable_entity } end endend\[/code\]endI don't have a view file because this program won't have a UI.I'm also having this and I think this is where it fails:**WARNING: Can't mass-assign these protected attributes: inventoryDocId, invoice_detail**
 
Back
Top