Your First App7:25 with Jay McGavren
We'll talk about how Sinatra can help you create web apps. Then we'll show you how to create and run a simple app.
If you'd like to know more about Ruby Gems and how they're installed, check out our RubyGems course.
We showed you how to set Sinatra's
:bind configuration option in this video, but that's just one of many options. If you'd like to learn about the rest, here's the official documentation.
Here are some possible problems you might encounter, along with potential solutions for each. If you can't solve your issue with what's here, use the link on this page to ask a question in our Community forum.
- Either the server isn't running, or your browser can't connect to the preview using the current options.
- Did you add
set :bind, '0.0.0.0'within your application code?
- Did you start the server from the console?
No "Port 4567" option in Workspace Preview menu:
- Previewing particular ports isn't available in some Workspace environments. Copy your code to a new Workspace based on the Ruby environment, and you should have the "Port 4567" option.
"This site can't be reached":
- Did you start the server from the console/terminal?
- Did you specify the port when typing a URL into your browser?
"Sinatra doesn't know this ditty":
- You're connected to the server, but Sinatra doesn't know how to handle your request.
- Did you make a typo in the URL?
- Did you make a typo when specifying the path in your code?
"Someone is already performing on port 4567.":
- Another app, possibly another Sinatra app, has already claimed port 4567 on your machine.
- Look for any other terminal windows that might be running a Sinatra app. If you find one, press Control-C to halt the app and free up the port.
- Try specifying a different port when you run your app. To run on port 4568, for example, use "
ruby myapp.rb -p 4568".
You need to sign up for Treehouse in order to download course files.Sign up