このためのデータベース設計を理解しようと懸命に努力していますが、完全には理解できません。
AUser
は many に属し、それぞれNetworks
に 1 つRole
ずつありNetwork
ます。複数のユーザーが(管理者、編集者、閲覧者など) にUsers
同じものを持っている場合がありRole
ます。Network
主なデータはEvent
. は、内の自分に基づいてUser
作成/表示/編集/破棄できます。Events
Role
Network
ユーザーはスルースルー経由でイベントにアクセスできますか?
class User < ActiveRecord::Base
has_many :roles
has_many :networks, :through => :roles
has_many :events, :through => :networks
end
class Role < ActiveRecord::Base
belongs_to :network
has_many :users
end
class Networks < ActiveRecord::Base
has_many :roles
has_many :users, :through => :roles
has_many :events
end
class Events < ActiveRecord::Base
belongs_to :network
has_many :roles, :through => :network
has_many :users, :through => :roles
end
私が探しているものから離れているのか、それとも本当に近いのかはわかりません。どんな助けでも大歓迎です。