Mass Assignment


  1. Use keyword arguments to define an initialize method.
  2. Use mass assignment to metaprogram an initialize method.


  • Create a Person class that accepts a hash upon initialization. The keys of the hash should conform to the attributes below:

allowable properties:

:name, :birthday, :hair_color, :eye_color, :height, 
:weight, :handed, :complexion, :t_shirt_size, 
:wrist_size, :glove_size, :pant_length, :pant_width
  • Each key in the attributes hash will become a property of an initialized Person instance. So, you should make an attr_accessor for each of the above properties


bob_attributes = {name: "Bob", hair_color: "Brown"}

bob =       # => "Bob"
bob.hair_color # => "Brown"

susan_attributes = {name: "Susan", height: "5'11\"", eye_color: "Green"}

susan =      # => "Susan"
susan.height    # => "5'11""
susan.eye_color # => "Green"
  • Your initialize method should use iteration and the .send method to mass assign the value of each key/value pair to its associated key (i.e. method). Refer to the previous reading to help you solve this one.

View Mass Assignment on and start learning to code for free.

View Mass Assignment Lab on and start learning to code for free.

Unlock your future in tech
Learn to code.

Learn about Flatiron School's Mission

With a new take on education that falls somewhere between self-taught prodigy and four-year computer science degree, the Flatiron School promises to turn students with little programming experience into developers.

In the six months since the Manhattan coding school was acquired by WeWork, it has spawned locations in Washington, D.C., Brooklyn, and London. Now, WeWork is opening a fourth Flatiron School location, this time in Houston.

Adam Enbar, Flatiron School's cofounder, believes now is the time to grow. "How the world is changing has impacted working and learning in very similar ways. We think education fundamentally is about one thing: enabling people to pursue a better life."

Learn. Love. Code.
Students come to Flatiron School to change their lives. Join our driven community of career-changers and master the skills you need to become a software engineer or a data scientist.
Find Us