开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜