Confusion in converting Sinatra form to Rails

After finishing Michael Hartl's tutorial on Rails, I'm trying to build a
call-tracking app with Twilio, to get a sense of things.

So far, I've managed to make an authentication system, a plans system,
integrated stripe, and integrated the creation of Twilio subaccounts
with user signup.

Now, I'm looking to figure out how to get users to search for a phone
number, choose from the list, and buy the phone number.

They have documentation on this here -- >
http://www.twilio.com/docs/howto/search-and-buy

But, the Sinatra is really confusing me. I'm not sure how to separate
the views from the controllers while looking at that code.

Currently, I have 2 relevant models

The User model, which has_many phone numbers.

I tried creating a new controller, the find_numbers controller, that
would do the search for the numbers, and transmit the chosen number to
the phone_numbers controller, but ended up riddled with errors.

Could someone give me pointers on how I would convert the following to
Rails controller/views?