Sha256: 64e43b6bf92b48042217422f157fbe37c407d5a0f218a598df44c48fc3414647
Contents?: true
Size: 761 Bytes
Versions: 1
Compression:
Stored size: 761 Bytes
Contents
class Activity < ActiveRecord::Base # Associations belongs_to :project belongs_to :person validates :project, :presence => true, :allow_blank => false validates :person, :presence => true, :allow_blank => false # Scopes scope :by_date, lambda {|value| where(:date => value)} # Duration validates :duration, :presence => true, :format => {:with => /[0-9]{1,2}([:.][0-9]{1,2})/} validates_date :date, :allow_nil => false, :allow_blank => false def duration=(value) if value.match(/:/) hours, minutes = value.split(':') write_attribute(:duration, hours.to_i + BigDecimal.new(minutes) / 60) else write_attribute(:duration, value) end end def to_s "%s: %0.2fh" % [project.name, duration] end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
bookyt_projects-0.13.0 | app/models/activity.rb |