Neugkeiten Verwalten..

This commit is contained in:
Andreas Stephanides
2013-09-01 10:44:27 +02:00
parent 9f2c184e43
commit 4dbe3f90b4
6 changed files with 106 additions and 45 deletions

View File

@@ -24,6 +24,8 @@ class Neuigkeit < ActiveRecord::Base
mount_uploader :picture, PictureUploader
scope :published, -> {where("datum <= ? AND datum IS NOT NULL", Time.now.to_date).order(:datum).reverse_order}
scope :recent, -> { published.where("updated_at >= ? ",Time.now - 7.days)}
scope :unpublished, -> {where("datum >= ? OR datum IS NULL", Date.today)}
scope :public, ->{includes(:rubrik).where("rubriken.public"=>:true)}
def datum_nilsave
self.datum.nil? ? Time.now + 42.years : self.datum
end