Migrate database and models for study-group-based authorization

This commit is contained in:
Sebastian Serth
2022-09-20 16:14:06 +02:00
committed by Sebastian Serth
parent ec4c6207f0
commit 04ed45ea73
9 changed files with 79 additions and 3 deletions

View File

@ -4,5 +4,11 @@ class StudyGroupMembership < ApplicationRecord
belongs_to :user, polymorphic: true
belongs_to :study_group
enum role: {
learner: 0,
teacher: 1,
}, _default: :learner, _prefix: true
validates :role, presence: true
validates :user_id, uniqueness: {scope: %i[user_type study_group_id]}
end