Skip to content

Instantly share code, notes, and snippets.

@laspluviosillas
Last active October 18, 2017 16:20
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 laspluviosillas/7360682 to your computer and use it in GitHub Desktop.
Save laspluviosillas/7360682 to your computer and use it in GitHub Desktop.
Interview Question #1
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