We start by deploying a Ruby on Rails application to production. We do that really quickly starting from nothing using all the tools in the box: rails, bundler, git, heroku, and URL forwarding.
Once we have our application in production, we take a deeper look at all the parts that were necessary to make it happen.
If you are just beginning with Ruby on Rails and you want to learn the full development workflow, from zero to production, then you should enjoy this course.
The Philosophy Of The Course
All the lectures are screencasts. This course focuses on the technologies and the practical work that goes into deploying a Rails application to production. The course values exact information and productivity.
We will be using the command line for almost everything. If you are not comfortable using the command line, you might want to read up before you start.
The Computer Setup
I am using Ubuntu to demo everything and I encourage you to use it as well. You can easily run Ubuntu alongside your current OS or from a USB stick. Download Ubuntu 13.10 here.
You could also stick with your current OS: the workflow demonstrated in this course should be very similar on other flavors of Linux or on Mac OS X.
Section 2 will spend a little bit of time talking about Ubuntu and the general computer setup. Feel free to use the course discussions if you have questions or problems.
In this lecture, we rush through the deployment of a Ruby on Rails application to Heroku (including a nice-looking public URL). The application we create is a basic bookshelf.
The rest of the course is dedicated to taking this demo apart and understanding each bit in the process.
Here are all the commands involved:
rails new up-and-running-with-ror cd up-and-running-with-ror rails server rails generate scaffold Book title:string author:string description:text rake db:migrate # edit config/routes.rb to make /books the root url rails server # edit Gemfile to use the gem pg on heroku bundle install git init git add . git commit -m "creates basic skeleton" heroku create up-and-running-with-ror git push heroku master heroku run rake db:migrate # edit the config at DNSimple to point to heroku heroku domains:add up-and-running-with-ror.com
An introduction to the software we will use in the course:
- Ubuntu 13.10
- Ruby 2.0
The rest will be installed through Ruby's package manager Rubygems.
This lecture covers the installation of the Ubuntu operating system. You will want to download the latest version for desktops: 13.10.
This lecture covers the installation of the Ruby programming language. Ruby version 2.0 or better is required.
On Ubuntu, just run:
sudo apt-get install ruby2.0 ruby2.0-dev
This lecture covers the basic usage of Ruby and the various ways to run Ruby code from the command line:
- Ruby scripts
- executable Ruby scripts
- ruby -e
This lecture covers the basic usage of Rubygems: the standard package manager for Ruby.
Rubygems was installed as part of Ruby. The executable is called "gem" and should be available on your command line.
As an example, to install a gem like kramdown, just run:
sudo gem install kramdown
This lecture covers the basic usage of Bundler: an easy way to manage the dependencies of any Ruby application.
Bundler expects a file called "Gemfile" in the directory where you run "bundle". The Gemfile contains a "source" line to indicate the source of the gems, and then a list of gems you depend on (one per line).
This lecture covers the basic usage of Rake: a simple task runner.
Task runners like Rake (or Make or Ant) are used to automate the everyday tasks of developers. When using Rails, a lot of tasks are executed through Rake—for example running tests or updating the database schema.
This lecture covers the creation of a basic Rails application.
You can get started by running the following on your command line:
rails new UpAndRunning
You will then have a basic Rails application in the UpAndRunning directory.
This lecture covers scaffolding and simple database management.
Scaffolding is a great way to generate boilerplate code.
Database management is done through Rake tasks like "db:migrate".
Have a go at this quiz to confirm you know the basics of the Ruby ecosystem.
If this quiz gives you trouble, you might want to spend some time investigating Ruby on your own.
This lecture covers Version Control Systems and introduces Git.
To initialize a Git repository, run:
You can then add and commit files to it with:
git add <filename> git commit <filename> -m "commenting your commits is a good habit (also it's required)"
This lecture covers basic Git usage with a Ruby on Rails application as an example.
Most of the time—as you work on your application—you will be using the following commands:
git add . git commit -m "more changes"
Rinse and repeat.
Confirm you know the basic git commands with this quiz.
This lecture covers the installation of the Heroku toolbelt.
On Ubuntu, just run:
wget -qO- https://toolbelt.heroku.com/install-ubuntu.sh | sh
You can have a look at the official installation instructions.
This lecture covers the deployment of our application to Heroku.
We register our application with Heroku, we use Postgres in production mode, and we run the database migrations on Heroku.
Finally, our application is made public!
Here are the commands involved:
heroku create git push heroku master heroku run rake db:migrate
This lecture covers the basic concepts behind DNS.
You can see DNS as a public service that maps domain names to IP addresses. It is used transparently by your browser for every web site you go to.
In this lecture we configure the DNS records to use the Heroku domain name as an alias for ours.
Then we make Heroku aware of the new domain name like this:
heroku domains:add <domain-name>
The changes have to propagate throughout the DNS, but after a few minutes (or perhaps an hour), we can reach our application at the new domain.
I am a software engineer and I have been working with the web for about 10 years.
I like to coach other developers in the art of software design, testing and pair programming.
My courses and workshops focus on the practical work behind web development. I will not dwell on theoretical concepts. You will find my courses useful if you are trying to bridge the gap between the stuff you learn in class and the things you have to do at work. Or if you are a journalist or an entrepreneur and you want to learn to code quickly.
Web development has become a lot easier in the last few years. You should give it a shot!