Rails: Validating association after save?

前端 未结 4 2145
孤城傲影
孤城傲影 2021-02-08 02:51

I have a User model which has many roles. Roles contains a user_id field, which I want to validate_presence_of

The is

4条回答
  •  遥遥无期
    2021-02-08 03:37

    You must take a look at ActiveRecord's Callbacks. Probably you will use the before_validation to do it.

提交回复
热议问题