Getting a website going from scratch with Rails 4.0 and Ruby 2.0 can be done in a day; including getting it deployed to Heroku! Don't believe me? Let's just do it.


First you'll need to install RVM:

curl -L | bash -s stable

Install Rails 4.0

gem install rails -v "4.0.0"

Building a Website

For example purposes let's just get a blog and users. To get this going I will use a nice little tool called RailsWizard.

Items choosen from RailsWizard:

Now let's run the generated script:

rails new SampleApp -m -T

From here you'll be guided in setting up the database you want to use with ActiveRecord and creating your Heroku server,

Making a Blog

Change into your project's root directory and run the following:

rails g scaffold Post title:string body:text

Run the migrations:

rake db:migrate

We now have the core part of the website complete! But let's not stop here; let's make our URLs a little nicer with friendly_id.

Add the following to your Gemfile:

gem 'friendly_id', github: 'FriendlyId/friendly_id', branch: 'rails4'

Add an index to the slug column on the posts table:

rails g migration add_index_on_slug_to_posts slug:string:index

Run the migrations:

rake db:migrate

Now make your Post model look like this:

class Post < ActiveRecord::Base
  extend ::FriendlyId
  friendly_id :title, use: :slugged

  validates :title, uniqueness: true
  validates :body, presence: true

Let's push it live!

git add .
git commit -m "Adds a blog"
git push heroku master

That's it?

It's kind of hard to believe isn't it?

David Chapman is a Ruby on Rails developer at isotope|eleven with over 5 years development experience. He's currently majoring in Electrical Engineering with a minor in Computer Science at the University of Alabama at Birmingham. David is a Linux geek, a math geek, a physics geek, a serious gamer, and a reader of Reddit. His super power is eating chips and salsa.