JournalEntry.to_s()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
cc 1
c 2
b 0
f 1
dl 0
loc 3
rs 10
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