Recipe 1.9. Updating Rails with RubyGems


Problem

You've installed Rails using the gem command and probably other Ruby packages as well. You want to manage these packages and upgrade as new versions are released, without worrying about dependencies.

Solution

To upgrade Rails and the gems it depends on (e.g., rake, activesupport, activerecord, actionpack, actionmailer, and actionwebservice), type:

$ sudo gem update rails --include-dependencies             

Once you've updated the Rails gems, the only remaining step to upgrading your individual Rails applications (Version 0.14.0 and later) is to get the latest JavaScript libraries. Run the following command from your application's root directory:

~/project$ rake rails:update:javascripts             

Test your application to make sure that everything works with the updated libraries.

Discussion

RubyGems is Ruby's package manager. It provides a standard way to distribute third-party programs and libraries, called gems. It allows you to install and upgrade gems, while handling dependencies for you. The gem command-line utility lets you install, upgrade, remove, and inspect gems.

Using gem list, you can view which gems you have installed. To get a list of all your installed gems and their versions, use:

$ gem list --local             

Here's how to get a listing of all the gems that are available from the remote repository:

$ gem list --remote             

The syntax for the gem command is gem command [arguments...] [options...]. Many of the commands take either --local or --remote as arguments. To search your local repository as well as the remote repository for gems with "flick" in the name, use --both:

$ gem search --both flick             

Here's how to install a remote gem locally and build its RDoc:

$ sudo gem install --remote rails --rdoc             

To view detailed information about the contents of a gem, use the specification command:

$ gem specification rails             

You can run gem help or just gem (with no arguments) to get more information on available gem commands and options.

See Also

  • The RubyGems Project, http://rubygems.org




Rails Cookbook
Rails Cookbook (Cookbooks (OReilly))
ISBN: 0596527314
EAN: 2147483647
Year: 2007
Pages: 250
Authors: Rob Orsini

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net