Skip to content

Instantly share code, notes, and snippets.

@arieliten
Created December 19, 2011 19:37
Show Gist options
  • Save arieliten/1498541 to your computer and use it in GitHub Desktop.
Save arieliten/1498541 to your computer and use it in GitHub Desktop.
Para Mauricio: como obtener los numeros de telefonos asociados a una persona
class Person
has_many :person_telephones
...
def mobile_numer
phone = self.person_telephones.first(:conditions => ["`person_telephones`.kind = ?", 'KIND_MOBILE'])
phone.number if phone
end
def landline_numer
phone = self.person_telephones.first(:conditions => ["`person_telephones`.kind = ?", 'KIND_LANDLINE'])
phone.number if phone
end
## Luego en las vistas
# person.landline_number
# person.mobile_number
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment