Ruby on Rails: question about validates_presence_of

后端 未结 3 2218
离开以前
离开以前 2021-02-20 04:28

I have a relationship in my ActiveRecord based model that looks like:

belongs_to :foo

My model should always have foo defined in it for it to b

3条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-20 05:12

    You may want to consider validates_associated

    This will make sure that the association is valid.

提交回复
热议问题