Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby Build an Address Book in Ruby Search Appending Contacts

Henry Miller
Henry Miller
7,945 Points

What is going on???

Task 2 of challenge 1 in the search module is killing me. This seems so simple, what am I doing wrong???

address_book.rb
contact = Contact.new
contact.first_name = "My"
contact.last_name = "Name"

address_book = AddressBook.new
contact = address_book.push()

2 Answers

Bruce Canedy
Bruce Canedy
13,496 Points

step 1 is correct.

address_book = AddressBook.new

remember you created a new object "address_book" that contains an array called "contacts", so you want to add the "contact" you created early into the "contacts" array.

In you example you are assigning a new contact variable.

you need to do the following.

address_book.contacts.push(contact)

Also, you cannot add "end" or it won't pass