Class: C80NewsTz::Banner02
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- C80NewsTz::Banner02
- Defined in:
- app/models/c80_news_tz/banner02.rb
Class Method Summary collapse
-
.random_active ⇒ Object
выдать рандомный активный баннер если такового нету - вернётся null.
Class Method Details
.random_active ⇒ Object
выдать рандомный активный баннер если такового нету - вернётся null
11 12 13 14 15 16 17 18 19 20 21 |
# File 'app/models/c80_news_tz/banner02.rb', line 11 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 |