calentry dauer

This commit is contained in:
Andreas Stephanides
2013-11-12 21:07:42 +01:00
parent d5160b11e5
commit 7156b4e3b4

View File

@@ -13,7 +13,7 @@
#
class Calentry < ActiveRecord::Base
attr_accessible :ende, :start, :summary, :typ,:calendar_ids, :calendar
attr_accessible :ende, :start, :summary, :typ,:calendar_ids, :calendar, :dauer
belongs_to :calendar
belongs_to :neuigkeit
validates :start, :presence => true
@@ -38,6 +38,12 @@ validate do |entry|
def start1
start.to_date
end
def dauer
self.start-self.ende
end
def dauer=(dauer)
self.ende=self.start+dauer.to_i.hours
end
def name
unless self.object.nil?
self.object.name