0

我有 4 张桌子:

A has many B
B belong_to A

C has many D
D belong_to C

A has_one C
B has one D

From:编辑,插入到B

row 1 
row 2

模型

def self.build_width_invoice(hash1, hash2)
    doc = Doc.new(hash1) # hash hash B_attributes
    doc.build_C(hash2)  # hash hash D_attributes
    doc
end

控制器

obj = A.build_width_invoice(hash1, hash2)
obj.save

save to A, B
        C, D   ok

每个 id 关系都已填充但 id_D int table B 没有值

数据B和D相同

我怎样才能插入它?

4

0 回答 0