Turn blank canonical url into nil (#2821)

This commit is contained in:
Ben Halpern 2019-05-13 16:57:36 -04:00 committed by GitHub
parent b2110d2d85
commit aa68fee630
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -55,6 +55,7 @@ class Article < ApplicationRecord
before_save :calculate_base_scores
before_save :set_caches
before_save :fetch_video_duration
before_save :clean_data
after_save :async_score_calc, if: :published
after_save :bust_cache
after_save :update_main_image_background_hex
@ -599,6 +600,10 @@ class Article < ApplicationRecord
title.to_s.downcase.parameterize.tr("_", "") + "-" + rand(100_000).to_s(26)
end
def clean_data
self.canonical_url = nil if canonical_url == ""
end
def bust_cache
return unless Rails.env.production?