开发者

Rails 2.3.x belongs_to association required by default?

In Rails 2.3.8, if I specify a relationship in my model as:

belongs_to :foo

Is that implicitly required now? If I want this model to always specify mymodel.foo when a new record is being validated, am I still required to use validates_p开发者_JAVA百科resence_of :foo?


No, it's not implicitly required; you need to validate the presence if needed.

Sometimes you want to have a belongs_to relationship where the parent_id is nullable, so these are treated as separate things.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜