Best practice about empty belongs_to association

后端 未结 2 1022
情书的邮戳
情书的邮戳 2021-01-30 19:41

Imagine the following situation:

I have a dog model and a house model. A dog can belong to a house, and a house can have many dogs, so:

2条回答
  •  佛祖请我去吃肉
    2021-01-30 20:15

    I think it is absolutely normal approach.

    You can just leave house_id with null value in database for the models which don't belong to other.

提交回复
热议问题