From 62de6f96f2a97a7c60da1bf1197fe65c9b761494 Mon Sep 17 00:00:00 2001 From: Martin Fenner Date: Wed, 7 Apr 2021 09:41:02 +0200 Subject: [PATCH] keep related_items as virtual attributes --- app/controllers/datacite_dois_controller.rb | 1 - app/models/doi.rb | 16 ++++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/app/controllers/datacite_dois_controller.rb b/app/controllers/datacite_dois_controller.rb index d30374299..f8dc277b5 100644 --- a/app/controllers/datacite_dois_controller.rb +++ b/app/controllers/datacite_dois_controller.rb @@ -1112,7 +1112,6 @@ def safe_params dates identifiers relatedIdentifiers - relatedItems fundingReferences geoLocations rightsList diff --git a/app/models/doi.rb b/app/models/doi.rb index d320a7cb7..250680217 100644 --- a/app/models/doi.rb +++ b/app/models/doi.rb @@ -121,7 +121,7 @@ class Doi < ApplicationRecord validate :check_landing_page, if: :landing_page? validate :check_identifiers, if: :identifiers? validate :check_related_identifiers, if: :related_identifiers? - validate :check_related_items, if: :related_items? + # validate :check_related_items, if: :related_items? validate :check_funding_references, if: :funding_references? validate :check_geo_locations, if: :geo_locations? validate :check_language, if: :language? @@ -1656,14 +1656,14 @@ def identifier normalize_doi(doi, sandbox: !Rails.env.production?) end - # disable virtual attributes, as database has been migrated - # def related_items=(value) - # write_attribute(:related_items, value) if has_attribute?(:related_items) - # end + # disable virtual attributes when database has been migrated + def related_items=(value) + write_attribute(:related_items, value) if has_attribute?(:related_items) + end - # def related_items - # read_attribute(:related_items) if has_attribute?(:related_items) - # end + def related_items + read_attribute(:related_items) if has_attribute?(:related_items) + end def client_id client.symbol.downcase if client.present?