@@ 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 | # |
@@ 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 |