我面临着组成关联的问题。
事实证明
我有一个user
,user
可以有很多photo booths
。
也photo booths
可以有很多users
。
这个问题解决了,但是我有Group photo booths
。
Group photo booths
可以有很多users
很多photo books
。所以
GroupPhotoBooth
有很多User
和PhotoBooth
PhotoBooth
有很多 User
和一个GroupPhotoBooth
User
有很多 PhotoBooths
和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
但是这个命令让我很困惑。我该怎么办?