Setting Up a Rails Stack

A Rails stack is the set of components you need to develop and run a Rails application. The Rails stack on each of our preferred operating systems is fairly similar and consists of the following:

  • Ruby

    Ruby is a general purpose programming language. It is open source, making it free to use, modify, and distribute. This means that you won't have to pay a license fee to use it. We'll be using Ruby version 1.8.4 throughout the book.

  • Rubygems

    This is the packaging system used for the majority of Ruby libraries (packaged Ruby libraries are called gems). The version used in this book is 0.9.3 .

  • Rails

    Rails is actually composed of several related gems (see previous bullet point), each of which needs to be installed to get a working Rails environment. Note that this book is based on version 1.2.3 of Rails (current at the time of writing, with version 2 still under development).

  • Other libraries

    There are several other libraries which are useful for Rails development, for example:

    • Capistrano (to help with deployment)
    • Mongrel (for serving Rails applications); note that other servers such as Lighttpd can be used as an alternative to Mongrel.
  • A database

    This can either be a file-based database (like SQLite) or a database running on a server (like MySQL or PostgreSQL). MySQL is used here, as it is thoroughly integrated with Rails and is extremely stable. It is also worth installing the MySQL bindings for Ruby for better performance.

  • An editor

    A programmer's editor or Integrated Development Environment (IDE) will make your life easier. We will be using EasyEclipse, but you can use whichever editor or IDE you prefer. Some popular alternatives are covered in the section: Installing an IDE later in this chapter.

The easiest route to setting up a Rails stack is to use a bundle—an integrated package which provides all of the pieces you need in a Rails development environment. This option is described briefly in the next section.

However, it is a good idea to learn how to install the components of the Rails stack yourself, rather than using a bundle. This gives you maximum flexibility and an insight into what makes your Rails applications tick. This is the approach we'll be taking.

At the end of this section, we'll see how Acme sets up their Rails development machines, as an example of how to put these recommendations into practice.

Installing a Rails Stack Using a Bundle

An easy-to-install bundle exists for each of the operating systems we are considering (Windows, Mac OS X, and Linux), handily packaging an entire Rails stack. If you already have one or more components installed (e.g. you already have a web server or database server), they can make things more complicated and create conflicts, which are difficult to troubleshoot. We are not going to spend much time covering installation of these packages (they're supposed to be easy, and are covered extensively elsewhere), but here are some pointers.

  • InstantRails

    The easy way to install Rails on Windows. It packages Ruby, all the Rails libraries, plus some extras into a single zip file. Installing it is as easy as unpacking the package and running an executable. You can get it from the following link: http://rubyforge.org/projects/instantrails.

  • Locomotive

    A one-click installer for Mac OS X, with a similar set of features to InstantRails. However, it also provides capabilities for running multiple versions of Ruby and Rails simultaneously. You can get it from the following link: http://locomotive.raaum.org/.

  • AxleGrease

    An add-on for XAMPP on Linux. XAMPP itself is an Apache, MySQL, PHP, and Perl installer for Mac OS X, Linux, or Windows. It is available at http://apachefriends.org/en/xampp.html. AxleGrease extends XAMPP by providing Ruby, the Rails gems, and various useful libraries, plus scripts to ease deployment of Rails applications to the XAMPP Apache server. It should be installed on top of a valid XAMPP installation. You can get it from the following link: http://rubyforge.org/projects/rorox/.

While Rails bundles provide low-friction installation, you can gain complete control over your environment by understanding a bit more about how to install the components yourself. This approach is covered in the following sections. (You'll still need to install an editor or IDE of some kind, so you may need to refer to that section even if you are using a bundle.)

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.12.162.37