Study   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 16
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A to_s() 0 3 1
1
# frozen_string_literal: true
2
3
# Model to represent studies
4
class Study < ApplicationRecord
5
  has_one :schedule, inverse_of: :study, dependent: :destroy
6
  has_many :study_participants, inverse_of: :study, dependent: :destroy
7
  has_many :participants, through: :study_participants
8
9
  validates :name, presence: true
10
  validates_uniqueness_of :name
11
  validates_length_of :name, \
12
                      within: 2..50, \
13
                      too_long: 'pick a shorter name', \
14
                      too_short: 'pick a longer name'
15
  
16
  def to_s
17
    name
18
  end
19
end
20
21
# == Schema Information
22
#
23
# Table name: studies
24
#
25
#  id         :integer          not null, primary key
26
#  name       :string           not null
27
#  created_at :datetime         not null
28
#  updated_at :datetime         not null
29
#
30
# Indexes
31
#
32
#  index_studies_on_name  (name)
33
#
34