ResponseScale.to_s()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
dl 0
loc 3
rs 10
c 1
b 0
f 0
1
# frozen_string_literal: true
2
3
# == Schema Information
4
#
5
# Table name: response_scales
6
#
7
#  id         :integer          not null, primary key
8
#  name       :string           not null
9
#  created_at :datetime         not null
10
#  updated_at :datetime         not null
11
#
12
# Indexes
13
#
14
#  index_response_scales_on_name  (name)
15
#
16
17
# Table name: response_scales
18
#
19
#  id   :integer          not null, primary key
20
#  name :string           not null
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