Total Complexity | 1 |
Total Lines | 13 |
Duplicated Lines | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 1 |
1 | # frozen_string_literal: true |
||
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 | |||
34 |