Sha256: 5b778b28f8d743bb3267296d7c2e6ee0cd4d3fb55c028f3f3115de2b55f30f68
Contents?: true
Size: 886 Bytes
Versions: 6
Compression:
Stored size: 886 Bytes
Contents
# баннер в области №2, перед содержимым страницы module C80NewsTz class Banner02 < ActiveRecord::Base mount_uploader :image, Bimage02Uploader validates_with BannerValidator before_save :before_save_format_href # выдать рандомный активный баннер # если такового нету - вернётся null def self.random_active result = nil a = self.where(:is_active => true) if a.count > 0 b = a.offset(rand(a.count)).first if b.image.present? result = b end end result end private # каждая ссылка должна начинаться с http:// def before_save_format_href str = 'http://' if self.href[0..6] != str self.href = "#{str}#{self.href}" end end end end
Version data entries
6 entries across 6 versions & 1 rubygems