Created
December 19, 2011 19:37
-
-
Save arieliten/1498541 to your computer and use it in GitHub Desktop.
Para Mauricio: como obtener los numeros de telefonos asociados a una persona
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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