I was faced with the problem of composing associations.
It turns out that
I have a user
, user
can have many photo booths
.
also photo booths
can have many users
.
This problem is solved, but I have Group photo booths
.
Group photo booths
can have many users
and many photo books
.
So
GroupPhotoBooth
has many User
and PhotoBooth
PhotoBooth
has many User
and one GroupPhotoBooth
User
has many PhotoBooths
and GroupPhotoBooths
class User < ApplicationRecord
has_many :group_photo_booths
has_many :photo_booths
end
class GroupPhotoBooth < ApplicationRecord
has_many :photo_booth
has_many :photo_booths
end
class PhotoBooth < AplicationRecord
belongs_to :group_photo_booths
has_many :users
end
But this order confuses me very much. What do i do?