ruby - Is there any way to implement a "has one of each" relationship in rails? -


say have 3 models users, roles, , events. each user can have many roles (e.g. guitarist, bassist, etc) , each role can have 1 or more users (e.g. ted can act guitarist or bassist) can fulfil it.

i'm creating rota application church band, means every event has 1 of each role in band , 1 user fill each role per event. wondering there way of enforcing relationship in model or whether had somewhere else in application. in advance!

event should have many users through eventparticipation , eventparticipation should

belongs_to :user belongs_to :event 

put uniqueness validation user_id, add role_id , scoped uniqueness validation if want.


Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c++ - Using OpenSSL in a multi-threaded application -

All overlapping substrings matching a java regex -