Let's Build Application with Ruby on Rails
Tags: ruby, rails, github, tutorial
Published: 2020-12-07 02:12:54


# What is Ruby on Rails

Ruby on Rails is the most popular server-side web application framework that is written in [Ruby](https://www.ruby-lang.org/en/) (open-source programming language).

You’ve probably already used many of the applications that were built with [Ruby on Rails](https://rubyonrails.org/), some of those big names are: [Hulu](https://www.hulu.com/welcome), [Instacart](https://www.instacart.com), [Basecamp](https://basecamp.com/), [GitHub](https://github.com), [Shopify](https://www.shopify.com/), [Airbnb](https://www.airbnb.com/), [Zendesk](https://www.zendesk.com/), [Square](https://squareup.com),  [Crunchbase](https://www.crunchbase.com/), but there are hundreds of thousands of applications built with the framework since it was released in 2004.

Ruby on Rails is open-source software, and it's **free** to use.

# Installing Rails
To install Rails, use the gem install command provided by RubyGems:

```gem install rails```

You can verify that everything is installed correctly, by running the following:

```rails --version```

For example, I get "Rails 6.0.3.4". We are ready to continue.


# my_app Example


Open up a command line or terminal. To generate a new rails application, use rails new command followed by the name of your application:

```rails new my_app```

To switch to my_app's directory, we use the cd command, which stands for change directory.

```cd my_app```

The my_app directory has auto-generated files and folders, that's the structure of a Rails application. All those files and folders are created by default:

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/09wqfbptgw31m3odfcea.png)

Rails application logic is organized into 3 major layers: Model-View-Controller. The Model is where the "business logic" lives. The Controller routes the commands to the model. The View renders HTML or JSON templates as a view.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/4tl1ibho8llc7orvkei3.png)

The **model** is chiefly handled by Active Record (with some backup from Active Model). That's the framework for talking to the database. 
The **controller** is handled by Action Controller and the **view** by Action View, together presented as Action Pack.

In addition to these core frameworks, we also ship with Action Mailer, for sending HTML and plaintext emails. 

# Starting up the Web Server

## Creating the database
Before we startup the rails server, we need to create the database by running:
```rails db:create```

We have a functional Rails application already. To see it, we just need to start a web server on our development machine by running the following:
```rails s```

This will fire up Puma, a web server distributed with Rails by default. Open a browser window and navigate to http://localhost:3000 the Rails default information page looks like this:

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/t0i2lwqfcc9z25s99zve.png)

Ruby on Rails **my_app** is up and running.

To connect with me please check my [Github](https://github.com/ivanadokic), [LinkedIn](https://www.linkedin.com/in/ivana-dokic/) or [Twitter](https://twitter.com/LloydPile). 

Thanks for reading!