Test Setup Failed
Push — master ( 4fe2ba...480572 )
by Steven
01:42 queued 12s
created

JournalEntry.default_values()   A

Complexity

Conditions 2

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
c 1
b 0
f 0
dl 0
loc 6
rs 9.4285
1
# frozen_string_literal: true
2
3
# Model to represent patient journals
4
class JournalEntry < ApplicationRecord
5
  belongs_to :journal, inverse_of: :journal_entries, touch: true
6
  default_value_for :entry, ''
7
  default_value_for :entry_date, Time.now
8
  validates :entry, exclusion: { in: [nil] } # allow '' but not nil
9
  validates :entry_date, presence: true
10
  validates_uniqueness_of :entry_date, scope: :journal
11
  validates :journal, presence: true
12
13
  def to_s
14
    "#{entry_date} #{entry}"
15
  end
16
end
17
18
# == Schema Information
19
#
20
# Table name: journal_entries
21
#
22
#  id         :integer          not null, primary key
23
#  journal_id :integer          not null
24
#  entry_date :datetime         not null
25
#  entry      :text             default(""), not null
26
#  created_at :datetime         not null
27
#  updated_at :datetime         not null
28
#
29
# Indexes
30
#
31
#  index_journal_entries_on_entry_date  (entry_date)
32
#  index_journal_entries_on_journal_id  (journal_id)
33
#
34