This commit is contained in:
BoHung Chiu 2022-11-19 10:57:29 +08:00
parent 82497389d4
commit b494447f8d
1 changed files with 3 additions and 3 deletions

View File

@ -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