Ruby on Rails Chapter 2: A Demo App

Home / Technology / Ruby on Rails Chapter 2: A Demo App

Ruby blog

Hopefully you were not holding your breath waiting on me to post the follow up to my last blog about Ruby on Rails.

This chapter runs you through some basic Rails commands to get an upper level view of how the language and extensions work together. You also get introduced to the different states or environments of a RoR (Ruby on Rails) application. With a default setup of a RoR application you have at least 2 states: production and development.

Production – is a fully functional (hopefully thoroughly tested) version of your application.

Development  – is what its name says. Still under development. This could be for your first release or the latest and greatest update to any application.

This is one of the first things I noticed as I was reading through the chapter before jumping into coding. You can see the different environments in the Gemfile in Listing 2.1.

The listing shows that in the production environment we are using:

gem ‘pg’, ‘0.15.1’

While in the development environment we are using:

gem ‘sqlite3’, ‘1.3.8’

What does this mean exactly?

Those are two different database (DB) gems that are available for RoR applications. While we are developing we are using a simpler DB in SQLite. It is easier to install and implement — with the caveat that it is much less powerful than PostgreSQL.

I’m not going into more detail here. The important thing to note is that the environments are different and you want to make sure you are altering the correct environment when you are developing your application.

The next thing I noticed was the tutorial used a Scaffolding to show an upper-level overview of how RoR functions.2 I suggest spending an ample amount of time reviewing Listing 2.3 and the text that immediately before and after it. This section thoroughly explains the MVC process and how to use it in an RoR application.3

This section first introduces you to inheritance in RoR and all of its wonderful powers. The MicroPost data inherits the RESTful actions that are available through ActiveRecord. This allows us to map the different actions, such as create, edit, destroy, update, etc in Lisiting 2.3 with its corresponding URL. Ex.) yourURL.com/users/edit

Hopefully this chapter went pretty well for you as it is fundamental building blocks of what is coming next.

1. Personally, I would advise making your production and development environments identical to avoid any potential issues that may arise during the process of altering your application into your production environment.

2. Scaffolding is not good for production level code.  It is bloated code that would potentially effect performance in a production environment.

3. I did not have a good understanding of how MVC worked when I first started and it was a significant hindrance to my progress.


Leave a Comment

eleven + 5 =