All pastes #161916 Raw Edit

Stuff

public text v1 · immutable
·published 2006-09-05 22:40 UTC
rendered paste body
class Person < ActiveRecord::Base
  set_table_name "people"
  
  has_many :phones, :dependent => :destroy
  has_many :addresses, :dependent => :destroy
  
  validates_presence_of :firstname
  validates_presence_of :surname
  #validates_uniqueness_of :email
  
  def main_phone
    for phone in self.phones
      if phone.phone.length > 1
        return phone
      end
    end
  end
  
  def caps_all
    self.attributes.each do |attribute| 
      puts "like ugh #{attribute}"
      #self.send(attribute)=self.send(attribute).upcase if attribute.is_a?(String)
      self.send(attribute+"=", attribute.upcase) if attribute.is_a?(String) 
    end
  end
  
  before_save :caps_all
  
  def main_address
    return self.addresses[0]
  end
  
  def validate
  end
end