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.

404 CHAPTER 14 Deployment<br />

The first line here adds the lib directory of RVM to the load path (represented in Ruby<br />

by $:). This is required so that this file knows where to find rvm/capistrano. Without<br />

it, it may fail.<br />

Now that you’re requiring rvm/capistrano when you run cap deploy again, you’ll<br />

see this additional output just after the stylesheets, javascripts, and images touching:<br />

* executing `bundle:install'<br />

* executing "ls -x /home/ticketeeapp.com/apps/ticketee/releases"<br />

servers: ["your-server"]<br />

[your-server] executing command<br />

command finished<br />

* executing "bundle install --gemfile [release_path]/Gemfile<br />

--path [shared_path]/bundle<br />

--deployment<br />

--quiet<br />

--without development test"<br />

servers: ["your-server"]<br />

[your-server] executing command<br />

command finished<br />

Bundler’s added a bundle:install task to your Capistrano configuration which runs<br />

after deploy:finalize_update. This task runs ls -x command at the beginning to<br />

get the last release’s directory (20110207202618, in this case), which it then uses to<br />

specify the location of the Gemfile using the --gemfile flag passed to bundle<br />

install. Rather than installing the gems to a system location which may not be writable<br />

by this user, 25 Bundler elects to install this to the /home/ticketeeapp.com/apps/<br />

ticketee/shared/bundler directory instead, specified by the --path flag.<br />

The --deployment flag specifies that the repository must contain a Gemfile.lock<br />

file (meaning the gem versions are locked) and that the Gemfile.lock file is up-to-date<br />

according to the Gemfile. This is to ensure that you’re running an identical set of<br />

gems on your server and local machines.<br />

Last, the --without flag tells Bundler what groups to ignore. The development<br />

and test groups are ignored in this case, meaning gems specified in these two groups<br />

will not be installed at all.<br />

With your application’s gems installed, you’re getting even closer to having an<br />

application running. When you deploy changes to your application, these changes<br />

may include new migrations, which will need to be run on the server after you do a<br />

deploy. You can deploy your code and migrate by running this lovely command:<br />

cap deploy:migrations<br />

After your code deploys, Capistrano will run the rake db:migrate task, which is of<br />

great use, because it sets up your database tables. You’ll see output like this:<br />

** [out :: [server]] (in [path_to_application])<br />

** [out :: [server]] == CreateProjects: migrating ===<br />

25 This directory would be located within /usr/local/rvm, which is only writable by members of the rvm group.<br />

This member is not a part of this group and thus is unable to install any gems at a system-wide level.

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

Saved successfully!

Ooh no, something went wrong!