开发者

Detaching a referenced record from a 1..N relationship, without deleting it

开发者 https://www.devze.com 2023-02-24 08:01 出处:网络
I have a 1..N relationship between two classes class A has_many: bees class B belongs_to: a I can add instances of B to bees collection without problem.

I have a 1..N relationship between two classes

class A
  has_many: bees

class B
  belongs_to: a

I can add instances of B to bees collection without problem. When I try to remove a specific instance of B, by doing

a.bees.where( id: someid ).delete

then a gets deleted...

Also tried

   b.a.delete

with t开发者_高级运维he same outcome How do I just delete the relationship, leaving the instances intact?


USe the nullify method.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号