From d2e71d65a424bdffde9ab3afda7e205229c07aff Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Gaya?= <sebastien.gaya@gmail.com>
Date: Thu, 23 Feb 2023 14:25:16 +0100
Subject: [PATCH] fix user dependent on papers

---
 app/models/user.rb                 |  1 +
 app/models/user/with_authorship.rb | 10 ++++++++++
 2 files changed, 11 insertions(+)
 create mode 100644 app/models/user/with_authorship.rb

diff --git a/app/models/user.rb b/app/models/user.rb
index 569270a99..2e984e029 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -57,6 +57,7 @@
 #
 class User < ApplicationRecord
   include WithAdminTheme
+  include WithAuthorship
   include WithAvatar
   include WithRegistrationContext
   include WithUniversity
diff --git a/app/models/user/with_authorship.rb b/app/models/user/with_authorship.rb
new file mode 100644
index 000000000..19e47a7ab
--- /dev/null
+++ b/app/models/user/with_authorship.rb
@@ -0,0 +1,10 @@
+module User::WithAuthorship
+  extend ActiveSupport::Concern
+
+  included do
+    has_many  :research_journal_papers,
+              class_name: "Research::Journal::Paper",
+              foreign_key: :updated_by_id,
+              dependent: :nullify
+  end
+end
-- 
GitLab