我正在开发rails 4应用程序,我有两个模型开发人员和应用程序。开发人员可以拥有许多应用,并且属于许多应用。 (应用程序的多个开发人员)我已经成功设置了一个连接表,一切正常但我希望扩展这一点,以便开发人员是:创建者,他可以有权访问编辑应用程序或只有访问权限的协作者该应用程序。有关最佳可能性的任何建议都是为了实现这一功能吗?
应用
has_and_belongs_to_many :collaborators, class_name: 'Developer', association_foreign_key: :collaborator_id
has_and_belongs_to_many :founders, class_name: 'Developer', association_foreign_key: :founder_id
开发
has_and_belongs_to_many :apps, foreign_key: 'collaborator_id'
has_and_belongs_to_many :apps, foreign_key: 'founder_id'
答案 0 :(得分:1)
我认为你需要创建另一个表:
def change
create_table :access_restricts do |t|
t.integer :user_id
t.integer :application_id
t.integer :role_id
t.timestamps
end
end
用户和应用程序将有许多assessment_restricts。
答案 1 :(得分:0)