如何在保存后复制tbl1
中tbl2
的数据?
结构
Tbl1. Customer
id | first_name | last_name | address
Tbl2. Address
id | customer_id | address
答案 0 :(得分:0)
如果您使用has_many
class Customer
has_many :addresses
after_save :create_address
private
def create_address
self.addresses.create(address: self.address)
end
end