forked from bofh/fetsite
AutoCommit Don Aug 27 15:03:02 CEST 2015
This commit is contained in:
@@ -14,14 +14,14 @@
|
||||
|
||||
class Calentry < ActiveRecord::Base
|
||||
attr_accessible :ende, :start, :summary, :typ,:calendar_ids, :calendar, :dauer, :object_id, :object_type
|
||||
belongs_to :calendar
|
||||
belongs_to :calendar, touch: true
|
||||
#belongs_to :neuigkeit
|
||||
validates :start, :presence => true
|
||||
validates :object, :presence => true
|
||||
validates :typ, :presence => true
|
||||
before_save :get_public
|
||||
belongs_to :object, polymorphic: true, touch: true # Objekt zu dem der Calentry gehört (derzeit ein Newsartikel)
|
||||
scope :of_month,(d) -> {where("start >= ? AND start <= ?", d.beginning_of_month, d.end_of_month)}
|
||||
scope :of_month, ->(d) {where("start >= ? AND start <= ?", d.beginning_of_month, d.end_of_month)}
|
||||
scope :upcoming, ->{ where("start >= ?", Time.now).order(:start)}
|
||||
scope :recent,-> { where("start <= ?", Time.now).order(:start).reverse_order}
|
||||
validate do |entry|
|
||||
@@ -31,7 +31,10 @@ class Calentry < ActiveRecord::Base
|
||||
end
|
||||
|
||||
resourcify
|
||||
|
||||
def self.updated_at
|
||||
#Calentry.select("MAX(updated_at) as m_updated_at").first.m_updated_at
|
||||
Calentry.all.max_by(&:updated_at).updated_at
|
||||
end
|
||||
def is_upcomming?
|
||||
self.start > Time.now
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user