27.02.2013 Views

Rails%203%20In%20Action

Rails%203%20In%20Action

Rails%203%20In%20Action

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

398 CHAPTER 14 Deployment<br />

The final line of this file is the most important, as it loads the config/deploy.rb file.<br />

This file contains the configuration for deploying your application. Everything in this<br />

file dictates how your application is deployed. We’ll go through it with you line by line,<br />

beginning with these two lines:<br />

set :application, "set your application name here"<br />

set :repository, "set your repository location here"<br />

When you call set in Capistrano, it sets a variable you (or Capistrano itself) can reference<br />

later. The application variable here should be the name of your application<br />

and the repository variable should be the path to your application. Change these<br />

lines to this:<br />

set :application, "ticketee"<br />

set :repository, "git://github.com/rails3book/ticketee.git"<br />

Deploying a branch<br />

When you deploy your application to the server, it will read from the master branch.<br />

If you’d like to change this, set the branch using this line in your configuration:<br />

set :branch, "production"<br />

You would also need to create this new branch in the GitHub repository called production<br />

with the git checkout -b production and git push origin production<br />

commands.<br />

For a good branching model, check out this post: http://nvie.com/posts/<br />

a-successful-git-branching-model/.<br />

On the next line of config/deploy.rb there’s the scm setting:<br />

set :scm, :subversion<br />

You’re going to use Git and not Subversion in this case, so change the line to this:<br />

set :scm, :git<br />

On the next few lines there are a couple of roles defined. These roles point to<br />

� web—The server or servers responsible for serving requests for your application<br />

� app—The server or servers where the application’s code is hosted<br />

� db—The server or servers where the database for the application is hosted<br />

Right now we won’t worry about multiple-server setups, focusing only on having everything<br />

on the one box. Your web, app, and db roles are all the same server in this<br />

instance. Therefore, you can replace those three lines with this:<br />

role :web, "[your-server]"<br />

role :app, "[your-server]"<br />

role :db, "[your-server]", :primary => true

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!