Code Duplication    Length = 14-16 lines in 2 locations

app/models/schedule.rb 1 location

@@ 4-19 (lines=16) @@
1
# frozen_string_literal: true
2
3
# Model to represent visit schedules
4
class Schedule < ApplicationRecord
5
  belongs_to :study
6
  has_many :arms, inverse_of: :schedule
7
8
  validates :name, presence: true
9
  validates :study, 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
#

app/models/response_scale.rb 1 location

@@ 24-37 (lines=14) @@
21
#
22
23
# Model to represent a response to an item
24
class ResponseScale < ApplicationRecord
25
  has_many :choices, inverse_of: :response_scale, dependent: :destroy
26
  has_many :items, inverse_of: :response_scale
27
  validates :name, presence: true
28
  validates_uniqueness_of :name
29
  validates_length_of :name, \
30
                      within: 2..50, \
31
                      too_long: 'pick a shorter name', \
32
                      too_short: 'pick a longer name'
33
34
  def to_s
35
    name
36
  end
37
end
38