Fix bug.
This commit is contained in:
parent
82497389d4
commit
b494447f8d
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue