diff --git a/app/models/communication/website/git_file.rb b/app/models/communication/website/git_file.rb index 88384f35813b4d6586345ac7292f34b7826107cb..d055984b8607a6f96ff6d599fe3ffe61170f2cfd 100644 --- a/app/models/communication/website/git_file.rb +++ b/app/models/communication/website/git_file.rb @@ -28,7 +28,7 @@ class Communication::Website::GitFile < ApplicationRecord def self.sync(website, object, destroy: false) # Permalinks must be calculated BEFORE renders - object.manage_permalink_in_website(website) + object.manage_permalink_in_website(website) if Communication::Website::Permalink.supported_by?(object) object.before_git_sync # Handle optional before-sync process git_file = where(website: website, about: object).first_or_create git_file.will_be_destroyed = destroy diff --git a/app/models/communication/website/permalink.rb b/app/models/communication/website/permalink.rb index bf8e902004275d2c48a1e0d83fad3c6db17ec19f..7e415d8c3432ca0ee1235d1e12a0763e8f2f6f7a 100644 --- a/app/models/communication/website/permalink.rb +++ b/app/models/communication/website/permalink.rb @@ -67,6 +67,10 @@ class Communication::Website::Permalink < ApplicationRecord false end + def self.supported_by?(object) + MAPPING.keys.include?(object.class.to_s) + end + def self.pattern_in_website(website) raise NotImplementedError end diff --git a/app/models/concerns/with_permalink.rb b/app/models/concerns/with_permalink.rb index 41172009f29ec49a142edb325868468ae8f55281..8b26356ffd98be4a55cff58d67b31ef652828182 100644 --- a/app/models/concerns/with_permalink.rb +++ b/app/models/concerns/with_permalink.rb @@ -24,7 +24,6 @@ module WithPermalink # Called from git_file.sync def manage_permalink_in_website(website) - return unless Communication::Website::Permalink::MAPPING.keys.include?(self.class.to_s) new_permalink_in_website(website).save_if_needed end