Issues (14)

app/models/study_participant.rb (1 issue)

1
# frozen_string_literal: true
2
3
# Association class between participants and studies
4
class StudyParticipant < ApplicationRecord
5
  belongs_to :participant, inverse_of: :study_participants
6
  belongs_to :study, inverse_of: :study_participants
7
  validates :participant, presence: true
8
  validates :study, presence: true
9
10
  validates_uniqueness_of :study, scope: :participant
11
  validates_uniqueness_of :participant, scope: :study
12
  
13 View Code Duplication
  def to_s
0 ignored issues
show
This code seems to be duplicated in your project.
Loading history...
14
    "#{participant} #{study}"
15
  end
16
end
17
18
# == Schema Information
19
#
20
# Table name: study_participants
21
#
22
#  id             :integer          not null, primary key
23
#  participant_id :integer          not null
24
#  study_id       :integer          not null
25
#  subject_number :string        
26
#  created_at     :datetime         not null
27
#  updated_at     :datetime         not null
28
#
29
# Indexes
30
#
31
#  index_participant_study                     (participant_id,study_id) UNIQUE
32
#  index_study_participants_on_participant_id  (participant_id)
33
#  index_study_participants_on_study_id        (study_id)
34
#  index_study_subject_number                  (study_id, subject_number)
35
#
36