Files
fetsite/app/models/calentry.rb
2013-08-22 16:38:33 +02:00

23 lines
533 B
Ruby

class Calentry < ActiveRecord::Base
attr_accessible :ende, :start, :summary, :typ,:calendar_ids
has_and_belongs_to_many :calendars
validates :start, :presence => true
validates :typ, :presence => true
validate do |entry|
if entry.ende.nil?
errors.add(:ende, "Es muss ein Endzeitpunkt vorhanden sein")
end
end
resourcify
def start_time
start
end
def start1
start.to_date
end
def name
summary
end
scope :upcoming, -> { where("start >= ?" , Time.now).where("start <= ?", 8.days.from_now) }
end