Skip to content

Foreman

Doc Ritezel edited this page Jan 5, 2013 · 4 revisions

Using Foreman

This article assumes you are using OSX, that you've seen the command line before, that you have a Rails app with Style Guide installed and that you've written at least one partial.

If you're new to the command line, consult the Terminal.app guide.

If you need to make a new Rails application, consult the Rails app guide.

If you need to install Style Guide, consult the install guide.

Let's say your application lives in ~/workspace/client-app for simplicity. When you see this, just mentally replace it with your application's directory.

Installing Foreman

Foreman is a great way to get your Rails app and Guard running side-by-side from a single command.

Let's open ~/workspace/client-app in Sublime Text, then open Gemfile and add Foreman as a dependency with the following line:

  gem "foreman"

Next, open a Terminal window and change to your application directory with cd ~/workspace/client-app.

You should see the foreman gem installation message.

Making a Procfile

Foreman uses a file called Procfile to run multiple commands. Each line of a Procfile is in the format name_of_command: command.

Let's open a new file in Sublime Text with Command+N. It will contain the following:

  web: bundle exec rails server
  guard: bundle exec guard

Then, save this file into ~/workspace/client-app/Procfile.

Fixing Guard

When running inside Foreman, Guard causes some strange things to happen. Let's turn Guard's interactive command line off by editing the Guardfile. Use Sublime Text to open ~/workspace/client-app/Guardfile and add the following line:

  interactor :off

Then, save the Guardfile.

Running Foreman

Back in our Terminal window, we can now run foreman start, and it will start both Rails and Guard simultaneously.

Clone this wiki locally