For example, for many-to-many models of User and Group, there is an intermediate table User_Group.
When creating a group, how do I validate that user_group keeps at least one record, i.e., it must be linked to the user?
in group.rb
validate:user_ids,presence:true
I think there is a way to describe as a candidate, but is there any other way?
How about making the intermediate table user_group_id
mandatory?
validate:user_group_id,presence:true
That's what it looks like.
© 2024 OneMinuteCode. All rights reserved.