diff --git a/app/models/journal.rb b/app/models/journal.rb index 6472d559d..57f53c125 100644 --- a/app/models/journal.rb +++ b/app/models/journal.rb @@ -45,7 +45,7 @@ class Journal < ApplicationRecord has_many :journal_details, :dependent => :delete_all has_many :attachments, as: :container, dependent: :destroy has_many :first_ten_children_journals, -> { order(created_on: :asc).limit(10)}, class_name: 'Journal', foreign_key: :parent_id - has_many :children_journals, class_name: 'Journal', foreign_key: :parent_id + has_many :children_journals, class_name: 'Journal', foreign_key: :parent_id, dependent: :destroy scope :journal_includes, ->{includes(:user, :journal_details, :attachments)} scope :parent_journals, ->{where(parent_id: nil)}