Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
551 views
in Technique[技术] by (71.8m points)

ruby on rails - How to validate uniqueness in join table record

I have 3 models: Open House, Attendee, and Registration (Registration is a join model to allow attendees to register for open houses. A registration belongs to an Open House and an attendee).

How do I create a validation on the Open House model that prevents an Attendee from registering twice for the same Open House?

I'm a little confused because the :attendee_id is on the Registration rather than the Open House, and that is the attribute that defines uniqueness in this scenario. Any help is appreciated!

question from:https://stackoverflow.com/questions/65945029/how-to-validate-uniqueness-in-join-table-record

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...