Skip to content
PLAY VIDEO PLAY VIDEO PLAY VIDEO
By Rachelle LeQuesne

WTF Just Happened? A Quick Tour of your first Rails App

WTF Just Happened? A Quick Tour of your first Rails App

You've just completed your first Installfest or Rails Girls. And you've not only built - but also published - your blog application! It's pretty awesome, right?

But then you get home and, after a few days, you take another look at your project. "What is all this stuff? I didn't write that!" There are so many folders and files, none of which you explicitly sat down and created. What are they all for?

After my first Rails Girls, I had this overwhelming desire to do an audit and remove what appeared to be superfluous code. The result? Well, predictably, my application broke and I had no idea what I needed to do to make it work again! It seems that all this "extra stuff" was necessary, after all. The only way I could get a working application again was rebuild it from scratch and not touch it. Being afraid to play with your app for fear of breaking it does nothing to help your learning.

This article will help break down what all this stuff is for and how it fits in. What you see here is a high-level overview, click on the links to read more detailed articles on each topic.

What is Ruby on Rails?

Ruby is a programming language developed in the mid-1990s. It is a scripting language that is also object-oriented.

Rails is a framework for building web applications. It is written in Ruby. When you create a new Rails application, the framework part of it provides you with certain core functionality that is common to all web applications. It is this provided functionality that makes Rails awesome. And also makes Rails confusing for people who are learning. :-)

Ruby Gems

Along with the built-in functionality provided for you by the Rails framework, there is a library of Ruby gems that you can add to enhance your project.

A gem provides instant functionality and reduces the amount of code that you need to write. A bonus to using gems is that they've been tested by developers in many live applications. This means that you can exclude them from your automated test scripts. Trust me, one less thing to test is always a good thing!

Rails uses two files to manage gems:

  • Gemfile, which is a list of all the gems to be installed, and
  • Gemfile.lock, which is a list of all the gems, together with their version, that have been installed in your application.

See Gems and Bundler for more detail on this topic.

Configuration Files

Configuration files allow you to customise the behaviour of your app. You will find them in the config directory of your Rails app.

See Rails Configuration Files for more detail on this topic.

REST, MVC and Rails Routing

Your Rails project is a REST-based web application that follows an MVC architecture. All those buzz-words might sound confusing but, don't worry, you will become familiar with them over time.

Rails achieves this with the following three folders:

  • app/models
  • app/views
  • app/controllers

and the file config/routes.rb.

When you typed rails generate scaffold Post (or Idea) in your Installfest (or Rails Girls) tutorial, you generated files that went into the models, the views, and the controllers folders. You also added a line to the routes.rb file so that your posts (or ideas) could be accessed via a URL in your browser.

See REST and Rails for more details on how Rails implements REST.

See MVC and Rails for more details on how Rails implements MVC (Model View Controller).

See Rails Routing for more details on Rails Routing.

Databases in Rails

Most web applications have a database attached to them.

Rails comes with SQLite database by default, and this is the database that we most commonly use in our development environment. When it comes to production, however, most developers will use something like PostgreSQL (arguably the most popular) or MySQL.

Schema definition (DDL) is done through the use of Migrations. These migration files can be found in the db/migrate folder. Data manipulation (DML) is done in Ruby through our Model.

See Database Migrations for more information on Migrations.

See MVC: Model for more information on communicating with our database through the Model layer.

Assets

All websites use CSS to style their pages and JavaScript to add functionality to the front-end. In Rails, we store these files under app/assets/stylesheets and app/assets/javascripts respectively. You may notice that the fonts and images that you might use in your app can also be found in the app/assets folders.

Rails uses a framework called the Asset Pipeline to compress these asset files. It is outside the scope of this article so it will not be covered here. If you are curious, please see Asset Pipeline for more details.

Other Useful Resources

This article is focussed on Ruby and Rails. However there are other concepts that you will need to understand to become a well-rounded Rails developer.

Below are some recommended resources for you to check out:

Summary

That is your Rails project in a nutshell. This is intended to be a living document, and will be updated based on feedback from you. If you have any questions or comments, please comment below or email me.

Latest Articles by Our Team

Our expert team of designers and developers love what the do and enjoy sharing their knowledge with the world.

We Hire Only the Best

reinteractive is Australia’s largest dedicated Ruby on Rails development company. We don’t cut corners and we know what we are doing.

We are an organisation made up of amazing individuals and we take pride in our team. We are 100% remote work enabling us to choose the best talent no matter which part of the country they live in. reinteractive is dedicated to making it a great place for any developer to work.

Free Community Workshops

We created the Ruby on Rails InstallFest and Ruby on Rails Development Hub to help introduce new people to software development and to help existing developers hone their skills. These workshops provide invaluable mentorship to train developers, addressing key skills shortages in the industry. Software development is a great career choice for all ages and these events help you get started and skilled up.

  • Webinars

    Webinars

    Webinars are our online portal for tips, tricks and lessons learned in everything we do. Make the most of this free resource to help you become a better developer.

    Learn more about webinars

  • Installfest

    Installfest

    The Ruby on Rails Installfest includes a full setup of your development environment and step-by-step instructions on how to build your first app hosted on Heroku. Over 1,800 attendees to date and counting.

    Learn more about Installfest

  • Development Hub

    Development Hub

    The Ruby on Rails Development Hub is a monthly event where you will get the chance to spend time with our team and others in the community to improve and hone your Ruby on Rails skills.

    Learn more about Development Hub

Next Community Events

Find more events

Get the “reinteractive Review” Monthly Email