From b494447f8df25fb498bdc835eef07720f7ad65f3 Mon Sep 17 00:00:00 2001 From: bohung Date: Sat, 19 Nov 2022 10:57:29 +0800 Subject: [PATCH] Fix bug. --- app/models/ad_image.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/ad_image.rb b/app/models/ad_image.rb index 129042f..07c815d 100644 --- a/app/models/ad_image.rb +++ b/app/models/ad_image.rb @@ -25,9 +25,9 @@ class AdImage belongs_to :banner - before_validation :add_http + before_save :add_http # validates :file, presence: true - validates :out_link, format: {:with=> /\A(http:\/\/|https:\/\/|\/)/i}, allow_blank: true + # validates :out_link, format: {:with=> /\A(http:\/\/|https:\/\/|\/)/i}, allow_blank: true # validates :title, presence: true scope :can_display, ->{self.and(AdImage.unscoped.or({:postdate.lte=>Time.now},{:postdate=>nil}).selector,AdImage.unscoped.or({:deadline.gte=>Time.now},{:deadline=>nil}).selector)} @@ -126,7 +126,7 @@ class AdImage def add_http unless self.out_link.blank? || self.out_link[/^http:\/\//] || self.out_link[/^https:\/\//] || self.out_link[/^\//] - self.out_link = 'http://' + self.out_link + self.out_link = 'https://' + self.out_link end end end