From 1277f7634650f9525d8ffea679c47a15833cbc87 Mon Sep 17 00:00:00 2001 From: Dries Steenhouwer Date: Thu, 5 Feb 2015 16:08:04 +0100 Subject: make homepage ready --- app/models/refinery/banners/banner.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'app/models') diff --git a/app/models/refinery/banners/banner.rb b/app/models/refinery/banners/banner.rb index 08b4b38..bccf63c 100644 --- a/app/models/refinery/banners/banner.rb +++ b/app/models/refinery/banners/banner.rb @@ -13,7 +13,7 @@ module Refinery validates_presence_of :start_date validates_length_of :title, :in => 0..255, :allow_nil => true validates_length_of :description, :in => 0..255, :allow_nil => true - + belongs_to :image, :class_name => '::Refinery::Image' has_and_belongs_to_many :pages, :class_name => '::Refinery::Page', :join_table => 'refinery_banners_pages' @@ -21,7 +21,7 @@ module Refinery banners = Arel::Table.new(::Refinery::Banners::Banner.table_name) where(banners[:expiry_date].eq(nil).or(banners[:expiry_date].gt(Time.now))) } - scope :active, where(:is_active => true) + scope :active, lambda { where(:is_active => true) } scope :published, lambda { not_expired.active.where("start_date <= ?", Time.now).order(:position) } @@ -29,6 +29,8 @@ module Refinery not_expired.active.where("start_date <= ?", Time.now).where("locale = ? or locale = ''", ::I18n.locale).order(:position) } + scope :in_category, ->(cat) { where(:category => cat)} + end end end \ No newline at end of file -- cgit v1.2.3