Class: C80NewsTz::Banner03
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- C80NewsTz::Banner03
- Defined in:
- app/models/c80_news_tz/banner03.rb
Class Method Summary collapse
-
.count_active ⇒ Object
выдать количество активных баннеров.
-
.random_active ⇒ Object
выдать рандомный активный баннер если такового нету - вернётся null.
Class Method Details
.count_active ⇒ Object
выдать количество активных баннеров
24 25 26 |
# File 'app/models/c80_news_tz/banner03.rb', line 24 def self.count_active self.where(:is_active => true).count end |
.random_active ⇒ Object
выдать рандомный активный баннер если такового нету - вернётся null
11 12 13 14 15 16 17 18 19 20 21 |
# File 'app/models/c80_news_tz/banner03.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 |