0

Rails 2.3.5、ruby 1.9.3、rubygems 1.8.24、および mac os x lion を使用しています。

cURL を使用して、このファイル「invoice.xml.erb」を渡します。

<invoice>
....
<invoice_detail>
....
</invoice_detail>
</invoice>

請求書のフィールドとinvoice_detailsのフィールドが入力されることを期待していましたが、cURLコマンドを渡すと、請求書フィールドのみが入力され、このエラーが発生します:警告:これらの保護された属性を一括割り当てできません: inventoryDocId、invoice_detail

ここに私のモデルがあります:

請求書.rb

class Invoice < ActiveRecord::Base
set_table_name "inventoryDocHeader"
set_primary_key "inventoryDocId"
has_many :invoice_detail, :foreign_key => "inventoryDocId"
attr_accessible :inventoryDocId, :originDocId, :siteCode, :transCode, :typeCode, :docCode,    :partyTerms,:locationCode, :otherCharges, :grossPrice, :netPrice, :amountPaid, :amountPending, :amountReturned, :RSiteCode, :RInventoryDocId, :RDocCode, :ROriginDocId, :batchCode, :partyCharges, :partyShipmentTermsText, :estimateVolume, :originCountryId, :consigneeName, :consigneeAddress1, :consigneeAddress2, :consigneeAddress3, :notifyPartyName, :notifyPartyAddress1, :notifyPartyAddress2, :notifyPartyAddress3

 end

請求書詳細.rb

class InvoiceDetail < ActiveRecord::Base
set_table_name "inventoryDocDetail"
belongs_to :invoice, :foreign_key => "inventoryDocId"
attr_accessible :inventoryDocId, :lineNumber, :parentLineNumber, :productCode,   :actualQuantity, :unitCode, :contentQuantity, :cost, :price, :commission, :factorRate, :referenceLineNumber
end

どんな提案でも大歓迎です。ありがとうございました!

4

1 に答える 1

0

:invoice_detail_attributes最初のエラーについては、attr_accessible コマンドに追加する必要があります。2 つ目は Invoice または InvoiceDetails モデルから取得していますか?

于 2012-05-23T07:47:27.297 に答える