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 Input and Output Searching the Address Book

Michael Cook
Michael Cook
5,864 Points

I don't know how to pass this challenge in Ruby "Building an Address Book"

Hi, so in this challenge task (I've already completed part one) it wants to to call 3 methods via one argument (It states that the methods exist outside the block of code I have), and I'm not exactly sure how to do that in this case maybe I forgot something along the way but I tried some different ways of doing so and all I got was either "Oops! Task One isn't responding!" (I don't think it says that but something similar) or "Bummer, try again!".

Sadly it doesn't help me when it just tells me "Bummer! Try Again!" or something similar. The code below is what is ONLY required to pass the first challenge. I just seem to get lost easy without the other part of the program that isn't visible to me.

Here is the question it's asking me.

"In the search method, call the find_by_name, find_by_address, and find_by_phone_number methods with the argument passed in to the search method. You can assume that these methods are already defined and do not have to write them."

All help is appreciated!

address_book.rb
class AddressBook
  def search(arg1)


  end
end

address_book = AddressBook.new

2 Answers

Jean Malan
Jean Malan
10,781 Points

Okay so there are three methods that exist namely: find_by_name, find_by_address, and find_by_phone_number methods.

Within the search() method you can call upon other methods to pass in the argument. So it will look like class

AddressBook
 def search( address_book1)
     find_by_name( address_book1)
     find_by_address ( address_book1)
     find_by_phone_number ( address_book1)

  end
end

address_book1 = AddressBook.new

That should work. But don't let the "Bummer" comments frustrate you. You need to try until you have done everything - including reading external material. That being said - Hope this works

Michael Cook
Michael Cook
5,864 Points

Thanks! That explained a lot! I managed to pass the task!