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 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