Skip to content

Instantly share code, notes, and snippets.

@mayra-cabrera
Last active April 6, 2016 20:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mayra-cabrera/02a51d157a0ad8df30f3 to your computer and use it in GitHub Desktop.
Save mayra-cabrera/02a51d157a0ad8df30f3 to your computer and use it in GitHub Desktop.

Suponiendo la siguiente información en una base de datos:

Employee

Id name organization_id
1 Kaitlin 1
2 Vidal 1
3 Eliza 2

Organization

Id name
1 Marvin-Hintz
2 Waelchi Group

PhoneNumber

id number employee_id
1 2512043784 1
2 8656923391 1
3 5731212066 2

y las siguientes clases:

    class Employee
      belongs_to :organization
      has_many :phone_numbers
    end
    class Organization
      has_many :employees
    end
    class PhoneNumber
      belongs_to :employee
    end
  • Encuentra la compañia con id 2
  • Encuentra el personal de la compañia con id 1
  • Encuentra los números teléfonicos del personal de la compañia 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment