diff --git a/app/models/ad_image.rb b/app/models/ad_image.rb index 18ef018..a7c73fa 100644 --- a/app/models/ad_image.rb +++ b/app/models/ad_image.rb @@ -30,9 +30,9 @@ class AdImage validates :out_link, format: {:with=> /\A(http:\/\/|https:\/\/|\/)/i}, allow_blank: true # validates :title, presence: true - scope :can_display, ->{self.and(AdImage.or({:postdate.lte=>Time.now},{:postdate=>nil}).selector,AdImage.or({:deadline.gte=>Time.now},{:deadline=>nil}).selector)} - scope :is_expired, ->{self.and(AdImage.or({:deadline.lte=>Time.now}).selector)} - scope :not_expired, ->{self.and(AdImage.or({:deadline.gte=>Time.now},{:deadline=>nil}).selector)} + 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)} + scope :is_expired, ->{self.and(AdImage.unscoped.or({:deadline.lte=>Time.now}).selector)} + scope :not_expired, ->{self.and(AdImage.unscoped.or({:deadline.gte=>Time.now},{:deadline=>nil}).selector)} after_save do if (self.video_file_changed? || self.auto_convert_video_changed?) && self.auto_convert_video