From aa68fee6302cff658e7576c688d8bd2ff8d5b208 Mon Sep 17 00:00:00 2001 From: Ben Halpern Date: Mon, 13 May 2019 16:57:36 -0400 Subject: [PATCH] Turn blank canonical url into nil (#2821) --- app/models/article.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/models/article.rb b/app/models/article.rb index 4457c9651..99bfb060e 100644 --- a/app/models/article.rb +++ b/app/models/article.rb @@ -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?