Last active
October 18, 2017 16:20
-
-
Save laspluviosillas/7360682 to your computer and use it in GitHub Desktop.
Interview Question #1
This file contains 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 Husband < ActiveRecord::Base | |
attr_accessible :full_name | |
has_one :wife | |
end | |
class Wife < ActiveRecord::Base | |
attr_accessible :full_name | |
belongs_to :husband | |
end | |
# Dado en una base de datos los siguientes datos (de ejemplo): | |
# Husbands: | |
# --------------------------- | |
# id | full_name | |
# --------------------------- | |
# 1 James Strong | |
# --------------------------- | |
# 2 Paul Brown | |
# --------------------------- | |
# Wives: | |
# ---------------------------------------- | |
# id | full_name | husband_id | |
# ---------------------------------------- | |
# 1 Melinda Strong 1 | |
# ---------------------------------------- | |
# 2 Sarah Brown 2 | |
# ---------------------------------------- | |
# | |
# | |
# Escribe codigo de rails que saque el output de *TODOS* los Husband/Wives en | |
# el sistema a un string/consola (puts) en este formato: | |
# James Strong : Melinda Strong | |
# Paul Brown : Sarah Brown |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment