我的模型的Rails可见性功能

时间:2018-03-20 19:55:12

标签: ruby-on-rails ruby-on-rails-5

我正在尝试为我的rails应用添加新功能。所以我有组织,活动,用户和团队模型。

class Organization < ApplicationRecord
  has_many :members, :dependent => :destroy
  has_many :users, :through => :members
  has_many :campains, :dependent => :destroy
  has_many :teams
end

class Campain < ApplicationRecord    
  belongs_to :user
  belongs_to :organization
end

class User < ApplicationRecord
  has_many :teamables, :dependent => :destroy
  has_many :teams, through: :teamables
end

class Team < ApplicationRecord
  belongs_to :organization

  has_many :teamables, :dependent => :destroy
  has_many :users, through: :teamables
end

我想管理广告系列可以选择谁可以查看广告系列。因此,当他进入管理编辑广告系列视图时,他可以选择一个用户可以查看广告系列的小组和/或选择可以查看广告系列的单个用户。

我是使用多对多多态关联的东西,但我不知道这样做的正确方法。

0 个答案:

没有答案
相关问题