Sha256: 9b6cea2b57ff4a4815ae1b96bd5d862999f565ba4040bbcb659948b143f43b1d
Contents?: true
Size: 852 Bytes
Versions: 1
Compression:
Stored size: 852 Bytes
Contents
class Employment < ActiveRecord::Base # Associations belongs_to :employee belongs_to :employer, :class_name => 'Company' # Validations validates_presence_of :employee, :employer validates_date :duration_from, :duration_to, :allow_nil => true, :allow_blank => true # Validity scope :valid_at, lambda {|value| where("duration_from <= :date AND (duration_to IS NULL OR duration_to > :date)", :date => value) } scope :valid, lambda { valid_at(Date.today) } def self.current(date = nil) date ||= Date.today valid_at(date).last end # String def to_s "%s bei %s von %s - %s" % [employee, employer, duration_from, duration_to] end # Attachments # =========== has_many :attachments, :as => :object accepts_nested_attributes_for :attachments, :reject_if => proc { |attributes| attributes['file'].blank? } end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
bookyt-0.0.1 | app/models/employment.rb |