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 | View Code Duplication | class ResponseScale < ApplicationRecord |
|
0 ignored issues
–
show
Duplication
introduced
by
Loading history...
|
|||
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 |