Files
codeocean/app/models/study_group.rb
Sebastian Serth 6e03939c10 Add StudyGroup to submissions and show it for submissions and RfCs
Also take care of deleting a StudyGroup for existing submissions
2019-03-06 14:00:58 +01:00

20 lines
566 B
Ruby

# frozen_string_literal: true
class StudyGroup < ApplicationRecord
has_many :study_group_memberships, dependent: :destroy
# Use `ExternalUser` as `source_type` for now.
# Using `User` will lead ActiveRecord to access the inexistent table `users`.
# Issue created: https://github.com/rails/rails/issues/34531
has_many :users, through: :study_group_memberships, source_type: 'ExternalUser'
has_many :submissions, dependent: :nullify
belongs_to :consumer
def to_s
if name.blank?
"StudyGroup " + id.to_s
else
name
end
end
end