I have a User model which has many roles. Roles contains a user_id field, which I want to validate_presence_of
User
roles
user_id
validate_presence_of
The is
You must take a look at ActiveRecord's Callbacks. Probably you will use the before_validation to do it.
before_validation