Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Ruby Building Web Apps with Sinatra ERB Templates The Root Path

Joel Cahalan
PLUS
Joel Cahalan
Courses Plus Student 4,499 Points

Sample code not working on my local machine

Here is my code. Getting an error when i try to view in my browser. What am doing wrong?

require "sinatra"

set :bind, "0.0.0.0"

get "/" do erb :welcome end

4 Answers

Matthew Carroll
Matthew Carroll
10,448 Points

What link are you trying to get to in your browser? I've copy and pasted your coded and it's working correctly for me. Ensure you're trying to visit the root path by just typing 'localhost:4567' in your address bar

Also, since you're running this on a local machine you can remove the

set :bind, 0.0.0.0

and just visit localhost:4567

Joel Cahalan
PLUS
Joel Cahalan
Courses Plus Student 4,499 Points

"just visit localhost:4567" helped me solve my issue. I still had "http://localhost:4567/wiki" in my browser from the previous excercise. Thanks!

Matthew Carroll
Matthew Carroll
10,448 Points

Not a problem, your error code helped.

When Sinatra does this:

#Try this: 
get '/wiki' do 
   "Hello World" 
end

It suggests that the route you're trying to visit doesn't exist.

If you tried to visit /monkeys for example it would say

#Try this: 
get '/monkeys' do 
   "Hello World" 
end
Matthew Carroll
Matthew Carroll
10,448 Points

Can you post the error you're getting? Is it just the 'Sinatra doesn't know this ditty' one?

Joel Cahalan
PLUS
Joel Cahalan
Courses Plus Student 4,499 Points

Sinatra doesn’t know this ditty.

Try this: get '/wiki' do "Hello World" end