Our First App

Set Up Starter App

For the first two sections of this book, we'll ask you to build up a blog app to learn Ruby on Rails. To get this started, follow the commands below to clone a starter app:

# make sure to use ruby version 2.6.0

$ git clone https://github.com/launchschool/demystifying_rails_app_template
$ cd demystifying_rails_app_template
$ bundle exec bundle install
$ bundle exec rails server

Once $ bundle exec rails server is running, just point your browser to http://localhost:3000/ to use the app.

Outlining Our First App

So now that we have a fresh Rails app up and running, let's make it respond to an HTTP request.

Specifically, let's say that we want a request from our browser to /hello_world to result in the text Hello, world! being displayed in the browser.

In Rails, this is essentially a two step process:

  1. define where the request should go
  2. define the code to handle a request of this kind

The first of these is accomplished by declaring a route.

The second, by defining a method on a controller. This type of method on a controller containing logic for handling a request is called an action.

In the next several chapters, we'll go through those steps to build up our first Rails app.