O'Reilly logo

Learning Sinatra by Manoj Sehrawat, Sudeep Agarwal

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The code

Now we know what we want to build. We also have a rough idea of what our file structure will be. When we run the application, the rackup file that we load is config.ru. This file tells the server what environment to use and which file is the main application to load.

Before running the server, we need to write some minimal code. It includes writing three files:

  • app.rb
  • config.ru
  • Gemfile

We can, of course, write these files in any order we want to, but we have to make sure that all three files have sufficient code for the application to work.

Let's start with app.rb.

app.rb

This is the file that config.ru loads when the application is executed. This file, in turn, loads all the other files that help it understand the available routes and underlying ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required