Your First Date with Rails — Build a simple Rails app

What is Ruby on Rails?

Ruby on Rails is a web application development framework used to develop from small to large scale web applications.

Model View Controller (MVC)

Before starting our code along, let’s first understand the basics of MVC (Model View Controller) structure of web application. Rails follows the MVC pattern of web applications. The MVC creates a separation from the presentation layer (Frontend) and the business logic (backend). These are pretty straight forward concepts, when we think about the frontend we’re talking about what the user interacts while the backend is all the logic that is happening under the hood, or in the back.

Let’s get to it

Have courage

First things first, to call Rails you need its number. Time to work on that charm (don’t you dare to use pick up cringe lines).

rails -v

Wanna have dinner sometime?

Remember to have code editor of your choice ready to go. I will be using Visual Studio for the examples on this blog post.

First stop

Now for our next task we will change the root route for something that we would like to display. Well, we want to take Rails to a nice restaurant. Not too fancy (you’re not desperate) but not too casual also, otherwise it will think you can’t be taken it serious (you’re going out for dinner not to watch the Super Bowl at a pub).

It’s alright. I know just the place

Let’s set up that method within the ApplicationController to handle this request. The application_controller.rb file has no code in it except for the class definition of ApplicationController that inherits from ActionController::Base.

Great for a quick hangout after work or a nice dinner.

The ace up your sleeve

Change of plans! Let’s reroute everything and do it properly this time. That place you know that you can always count on and also give an extra $20 bucks to your waiter buddy that he will get you that special corner that “was reserved JUST for you.

  1. You need a controller that is easy to spot with a suggestive name that will handle all your pages.
  2. Within that controller you need a method/action with an appropriate name.
  3. Under the Views directory, Rails will look for a folder with a similar name of your controller name. Within that folder Rails will look for the route you’re trying to set up, let’s call it: restaurant.html.erb.
It’s one of my favorite restaurants in New York city.


On this article you’ve learned:

  1. The basic concepts of MVC (Model View Controller)
  2. How to use the command line to create your Rails application.
  3. Where to find your Views and Controllers folders.
  4. How to connect your routes file to the right controller#action to properly render simple html to the page.
  5. Where to define your method/actions.
  6. How to display your html.erb extension files from the Views folder.
  7. How to make a great impression on your first date.

Get the Medium app