contactorama/app/models/address.rb

10 lines
318 B
Ruby

class Address < ActiveRecord::Base
has_many :contacts
# returns the address of the contact /w the given first + last name.
def self.by_first_and_last_name(firstname, lastname)
c = Contact.where("firstname = ? AND lastname = ?", firstname, lastname)
ret = c[0].address unless c[0].nil?
nil
end
end