一道有关Rails关联的新手问题。
我有一个Bug模型和一个Status模型。Status基本上只是一个键/值对表。在可用的选择中,我会说Bug has_one Status是最合适的。然而,根据这个:
“Content belongs_to ContentTemplate. Go back and look at how I described the problem, and you'll see that it works. With belongs_to, the table accepts responsibility for the foreign key. So Content has a content_template_id. And ContentTemplate doesn't need anything. I can point to it at will. Done.”
Bug belongs_to Status更为合适(因为Bug应该接受外键)。从语义上讲,他的例子很有道理,但我的没有。这只是Rails的一个怪癖,在这种情况下看起来很奇怪,还是我没有理解什么/做错了?
我有一个Bug模型和一个Status模型。Status基本上只是一个键/值对表。在可用的选择中,我会说Bug has_one Status是最合适的。然而,根据这个:
“Content belongs_to ContentTemplate. Go back and look at how I described the problem, and you'll see that it works. With belongs_to, the table accepts responsibility for the foreign key. So Content has a content_template_id. And ContentTemplate doesn't need anything. I can point to it at will. Done.”
Bug belongs_to Status更为合适(因为Bug应该接受外键)。从语义上讲,他的例子很有道理,但我的没有。这只是Rails的一个怪癖,在这种情况下看起来很奇怪,还是我没有理解什么/做错了?