This is a short guide on how to get started quickly with RailsBricks. For an in-depth tutorial, check out the RailsBricks tutorial at SitePoint.

1. Prerequisites

In order to use RailsBricks, you need the following prerequisites:

  • A computer running Linux or OS X
  • Ruby (at least version 2.0.0 or greater)
  • Some knowledge of Ruby on Rails development as RailsBricks automates trivial tasks but doesn’t replace writing code to implement your features! If you want to learn more about web development, check out my one-on-one online training sessions.

RailsBricks doesn’t run out of the box on Windows. If you plan to use RailsBricks on Windows, follow the Windows installation guide. You will first need to install the DevKit (thanks to David Camarena for pointing this out) as well as the tzinfo-data gem.

back to top

2. Installation

You install RailsBricks like any other gem. Open a terminal window and issue the following command:

gem install railsbricks

back to top

3. Creating a new Rails app with RailsBricks

From your terminal, go to the directory where you want your new app created and type:

rbricks -n

If this is your first time using RailsBricks, make sure you select to receive tips along the way. The wizard will hold your hand during the app creation.

A note on Ruby version support: RailsBricks generates Rails apps with support for the current major Ruby release (currently, 2.0.0) + the current point release and the previous one, for example 2.1.5 & 2.1.4. If you need to use another version of Ruby, you will have to manually edit the Gemfile after the app gets created.

back to top

4. Recreating the database

Once your application is built, if you need to recreate the database, you can run rbricks -r from within your app directory and it will drop, create, migrate and seed your database.

back to top

5. Updating annotations in models and routes

If you generate new models, update an existing one or add new routes, you can update the annotations (the comments at the top) within the relevant files with the command rbricks -a or rbricks --annotate.

back to top

6. Show what you do

If you have built an app using RailsBricks, send the link and your creation will be showcased on railsbricks.net!

back to top