contactorama/app/models/contact.rb

35 lines
926 B
Ruby

class Contact < ActiveRecord::Base
has_many :emails, :dependent => :destroy
has_many :phones, :dependent => :destroy
has_one :address
accepts_nested_attributes_for :emails, :reject_if => lambda { |a| a[:address].blank? }, :allow_destroy => true
accepts_nested_attributes_for :phones, :reject_if => lambda { |a| a[:nr].blank? }, :allow_destroy => true
def birth_date_string
s = birth_day.to_s || ""
s += "." unless birth_day.nil?
s += birth_month.to_s || ""
s += "." unless birth_month.nil?
s += birth_year.to_s || ""
end
def address_string
s = street || ""
s += " "
s += housenr || ""
s += "&middot;" unless (plz.nil? and place.nil?)
s += plz
s += " "
s += place
end
# very temporary
def twitter_username
"dummy"
end
def twitter_username_link
'<a href="http://twitter.com/' + twitter_username + '">@' + twitter_username + "</a>"
end
end