Aptana RadRails: An IDE for Rails Development - Ramirez Javier - E-Book

Aptana RadRails: An IDE for Rails Development E-Book

Ramirez Javier

0,0
20,53 €

-100%
Sammeln Sie Punkte in unserem Gutscheinprogramm und kaufen Sie E-Books und Hörbücher mit bis zu 100% Rabatt.

Mehr erfahren.
Beschreibung

In Detail

Aptana RadRails is an Integrated Development Environment for Ruby on Rails projects. Built on top of the well-known Eclipse platform, RadRails provides all the tools you need to create a whole Rails application from a single interface, allowing you to focus on the creative part of the development as your IDE takes care of the mechanics.

Who this book is for

This book is for Ruby on Rails developers who want to make the most of the framework by using an Integrated Development Environment.

Even though the book explains everything you need to follow the contents, the focus is on how to use the tool and not on the Rails framework itself, so previous working knowledge of Rails is highly advisable. Previous knowledge of Eclipse is not necessary.

Sie lesen das E-Book in den Legimi-Apps auf:

Android
iOS
von Legimi
zertifizierten E-Readern

Seitenzahl: 337

Veröffentlichungsjahr: 2008

Bewertungen
0,0
0
0
0
0
0
Mehr Informationen
Mehr Informationen
Legimi prüft nicht, ob Rezensionen von Nutzern stammen, die den betreffenden Titel tatsächlich gekauft oder gelesen/gehört haben. Wir entfernen aber gefälschte Rezensionen.



Table of Contents

Aptana RadRails: An IDE for Rails Development
Credits
About the Author
About the Reviewer
Preface
What This Book Covers
What You Need for This Book
Who This Book Is For
Conventions
Reader Feedback
Customer Support
Downloading the Example Code for the Book
Errata
Questions
1. Getting Started
Do I Need an IDE for Rails Development?
About Aptana RadRails
How Can Aptana RadRails Help Me?
Prerequisites
Java Virtual Machine
Ruby and Rails
Components to Install
Installing Rails if you already have Ruby and RubyGems
Installing Ruby and Rails on Linux
Installing Ruby and Rails Using yum
Installing Ruby and Rails Using apt
Installing Ruby and Rails on OS X
Installing Ruby and Rails on Windows
Supported Databases
Installing Eclipse
Installing Plugins in Eclipse
RadRails Installation
Summary
2. First Steps
Basic Configuration
Eclipse Preferences Dialog
File Encoding
Connecting through a Proxy
Ruby Environment
Rails Environment
Creating a Rails Project
Importing an Existing Project into RadRails
Working with Perspectives and Views
Eclipse Perspectives
Eclipse Views
Summary
3. Your First Application
Basic Views
The Ruby Explorer View
Ruby Explorer Top Icons
The Console View
The Generators View
Generating Models and Migrations
Running Your Migrations
Generating Scaffolds
Starting Your Server
Monitoring Your Server
Summary
4. Writing Ruby Code
A Quick Note about Keyboard Shortcuts
The Ruby Editor
Syntax Highlighting
Outlining the Structure of Your Ruby Code
Quick Outline
Type Hierarchy
General Outline View
Code Folding
Code Formatting
Indenting Code Blocks
Commenting Code Blocks
Code Completion
Code Templates
Defining Your Own Code Templates
Navigating Your Code
General Source Navigation Tools
Matching Brackets
Declarations of Classes, Modules, Methods, and Variables
Navigating Your MVC Code
Opening Types and Resources
Refactoring
Generate Accessors
Generate Constructors
Convert Local Variable to Field
Encapsulate Field
Extract Method
Extract Constant
Inline Method
Rename
Split Local Variable
Searching in Ruby Projects
Searching within the Current File
Searching across Multiple Files
Ruby Search
Call Hierarchy
Summary
5. Coding Rails Views
ERB/RHTML Templates
Views Navigation
View Templates
HTML Code Assist
Refactoring into Partials
Outline
Editing HTML Files
Editing JavaScript Files
Editing CSS Files
Summary
6. Debugging Your Application
Getting Started with Debugging
Debugger Configuration
Starting Your Server
Debugging a Ruby Script
Using Breakpoints
The Breakpoints View
Setting Generic Breakpoints for Exceptions
Exporting and Importing Breakpoints
The Debug View
The Debug View and the Stack Frame
Stepping through Your Application
Variables and Expressions
The Variables View
The Expressions View
The Display View
Useful Tools for Debugging
Linking Errors and Source Code from the Browser
Tailing the Log Files
Summary
7. RadRails Views
Opening the RadRails Views
Documentation Views
Ruby Interactive (RI) View
Ruby Core, Ruby Standard Library, and Rails API
Servers View
Starting a Server with Additional Arguments
Managing Non-Rails Servers from the Servers View
Launching External Tools from Eclipse
Rails Console
Rails Plugins View
RubyGems View
Rake Tasks
Generators View
Rails Shell View
RegExp View
Problems View
Tasks View
Test::Unit View
Summary
8. Configuration Reference
General
Appearance
Editors
Annotations
Linked Mode
Quick Diff
Spelling
Keys
Workspace
Aptana
Browsers/User Agents
Editors
Code Assist
Colors
Folding
Formatting
Typing
RHTML Templates
Start Page
Rails
Ruby
Appearance
Editor
Syntax Coloring
Errors/Warnings
Task Tags
Summary
9. Other Useful Plugins
Database Management
Installing DBViewer
Creating New Connections
DB Tree View
SQL Execute View
SQL History View
DBViewer Configuration
Version Control with Eclipse
Installing Subclipse
SVN Repository Exploration
Projects and Repositories
Checking out an Existing Project
Importing a New Project into a Repository
Update, Edit, Compare, and Commit
The Synchronize View
History View
Summary
Index

Aptana RadRails: An IDE for Rails Development

Develop Ruby on Rails applications fast using RadRails 1.0 Community Edition

Javier Ramírez

Aptana RadRails: An IDE for Rails Development

Develop Ruby on Rails applications fast using RadRails 1.0 Community Edition

Copyright © 2008 Packt Publishing

All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.

Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, Packt Publishing, nor its dealers or distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.

Packt Publishing has endeavored to provide trademark information about all the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.

First published: May 2008

Production Reference: 1190508

Published by Packt Publishing Ltd.

32 Lincoln Road

Olton

Birmingham, B27 6PA, UK.

ISBN 978-1-847193-98-8

www.packtpub.com

Cover Image by Nilesh R. Mohite (<[email protected]>)

Credits

Author

Javier Ramírez

Reviewer

Chris Williams

Acquisition Editor

Shayantani Chaudhuri

Adil Rizwan

Technical Editor

Bhupali Khule

Editorial Team Leader

Akshara Aware

Project Manager

Abhijeet Deobhakta

Indexer

Hemangini Bari

Proofreader

Chris Smith

Production Coordinator

Shantanu Zagade

Cover Work

Shantanu Zagade

About the Author

Javier Ramírez has been developing Web Applications since before the term Web Application was coined. Born in Zaragoza, Spain, in 1974, he started programming as a hobby around the age of 11 assisted by his older sister. A few years later, he got his first modem and became a regular of BBSes and Newsgroups. His interest in developing server applications that can be accessed remotely comes from those times.

He has learned—and forgotten—many programming languages, including Basic, dBase III, Cobol, Pascal, SQL, C, C++, ASP, TCL, JavaScript, PHP, and Java, the language on which he has focused for most of his career so far. He has held the positions of programmer, analyst, consultant, team leader, post-sales engineer, project manager, and software architect, totaling over 12 years in the IT business.

Having developed projects mainly for banks and other big corporations in Spain, Italy, and the US, he co-founded some years ago a small software development shop, which provided him with valuable experience about the difficulties and the joys of entrepreneurship. After two years, he left the company in pursuit of new professional challenges.

For the last two years, he has been proudly working for ASPgems, where he discovered Ruby on Rails, which soon became his framework of choice for developing Web Applications. He is one of the organizers of the Spanish Rails Conference, also participating as a Speaker in the two events held so far.

He has also been an instructor on Robotics, Java, FatWire Content Server, and Ruby on Rails, and a University Lecturer in the subjects of 'Software Engineering' and 'The Java Programming Language', which he currently teaches at Universidad Francisco de Vitoria, in Madrid.

Javier Ramírez holds a B.Sc. in Business Information Systems with First Class Honors and a degree in Ingeniería en Sistemas de Computación

This book would have not been possible in its present form if not for the work of the people at Packt Publishing. I'd like to thank specially to Acquisition Editor Shayantani Chaudhuri for giving me the opportunity to write this book and to Technical Editor Bhupali Khule for polishing the rough edges, which were many. Abhijeet, Adil, Shantanu, and Patricia also deserve to be in this list.

I would also like to acknowledge the fantastic work of the original team of RadRails, and also of the developers behind Eclipse. A big special thank you goes to Chris Williams, the current lead developer of Aptana RadRails and the technical reviewer for this book. He provided me with precious insight about a large number of issues. Of course, any errors that might remain in the book are my own.

Thanks to the people at ASPgems, for trusting me to join one of the most gifted team I know and for introducing me to Ruby on Rails.

I also have to thank Madzia, who gently allowed me to disappear for uncountable evenings and weekends during the last nine months without complaining—or without complaining much anyhow.

Finally, but not least important, I would like to thank my parents for supporting my education.

A part of this book—the good one—wouldn't have been possible without all of them.

About the Reviewer

Chris Williams has spent the last four years working on the Ruby Development Tools project to bring Ruby tooling to the Eclipse IDE, and has been the lead developer of RadRails since joining Aptana in the first half of 2007. Prior to joining Aptana, Chris has worked in R&D for both Paychex Inc. and the Xerox Corporation. Chris lives with his wife and dog in Rochester, New York.

Thanks to Kyle Shank, Matt Kent, and Marc Baumbach for creating RadRails; Markus Barchfeld for his work on RDT's debugger and builds; Jason Morrison for his work on type inferrencing; Mirko Stocker, Thomas Corbat, and Lukas Felber for their addition of refactoring support; Adam Williams for starting the RDT project; Paul Colton and Aptana for allowing me to work on RadRails full-time.

Lastly, I'd like to thank my wonderful wife, Lidza, for being patient and sharing a passion for our careers; and my dog Beaker for knowing when I need to take a walk.

Preface

Coming from a background of developing in languages such as Java, one of the things that surprised me the most about the Ruby and Rails community, was the common practice of not using an Integrated Development Environment. Most of the members of the community, including the most relevant, were comfortable with just a programmer's editor.

At first I thought it was because, Ruby being a dynamic language, using a full IDE might be an overkill. But then I thought of the PHP community, in which several IDEs are popular, with PHP also being a dynamic language. So I still had to guess why using an IDE was not a common practice within the Ruby on Rails world.

Nowadays, there is a growing list of IDEs with support for Ruby on Rails, but two years ago the options were really scarce. Back then, I chose to use RadRails because it worked on top of the Eclipse IDE—which was the tool I was already using for other programming languages—and because it was the only free, open source, and portable option.

Truth is, the first version of RadRails I used was very promising, but still a bit too basic. It featured just a few specialized tools, Ruby syntax colorization, and a slow and faulty code-assistance. As a result, the difference between RadRails and a good programmer's editor was not really significant. However, as Ruby on Rails gained popularity, RadRails was vastly improved, and a lot of new features were added.

At the same time, several other IDEs started to provide support for Ruby too. Today, even if many Ruby on Rails developers still don't use an IDE, a growing number of them already.

During these two years, I've been developing projects almost exclusively with Ruby on Rails; and I developed all of them using RadRails. Of course I have been keeping an eye on every new IDE with Ruby support, just to see if there were any reasons for changing, but I still didn't find any.

To me, writing this book is a way of contributing back to the RadRails project. I hope this book will help the existing community of users of Aptana RadRails, and will also help new users to start working with this tool. Besides, thanks to the Packt Open Source Project Royalty Scheme, a part of the benefits will be directly paid as a royalty to the RadRails project, so by purchasing this book you are funding a bit of the Community Edition of Aptana RadRails.

What This Book Covers

This book will show you how to get the most of the Community Edition of Aptana RadRails for developing Ruby on Rails projects. Apart from the features provided by RadRails, the book will give you an overview of working with the Eclipse IDE, and will show you how to use the Eclipse functionalities that are relevant for Ruby and Rails development.

This book is not about the Ruby programming language or the Ruby on Rails framework. Even if you don't need to be an expert, you should already be familiar with the language and the framework to get the most from this book.

Chapters 1 and 2 will show you how to install and configure Aptana RadRails, and will help you find your way around the Eclipse IDE. If you have previous experience with Eclipse , and you have already installed Aptana RadRails, then you can proceed directly to Chapter 3.

Chapters 3 to 8 are a complete reference to each of the components of RadRails, including all the configuration options.

Finally, in Chapter 9 you will find documentation about some complementary plugins you can use for connecting to a database and for managing your source repositories.

You can find below a brief introduction to each of the chapters.

Chapter 1: This chapter will introduce you the concept of IDE and will give you a general overview of what you can expect from Aptana RadRails. You will also find instructions about how to install Aptana RadRails and the Eclipse IDE in your system. Even if you should already be familiar with the installation of Ruby and Rails, the chapter also provides a quick reference for installing Ruby and Ruby on Rails on Windows, Linux, and OSX.

Chapter 2: In most cases, Aptana RadRails will work directly out of the box. However, in some cases you will need to make a minimal configuration of the IDE. The first part of this chapter will show you the basic configuration of RadRails.

Chapter 3: Two of the basic tools RadRails provides are the Ruby Explorer and the Console View. With the Ruby explorer you will be able to browse the structure of your projects and perform any kind of file-related operations, including working with the local history of your files. The console view will display the output of most of the processes we will launch from RadRails. Apart from learning how to use these views, we will show how to use Generators and Rake Tasks from Aptana RadRails to create a simple demo application. You will also learn how to start and stop your servers and how to use the built-in browser to watch your application in action.

Chapter 4 explains in detail all the built-in capabilities of RadRails for developing Ruby code. You will learn to use the Ruby Editor to write your source code, to navigate between the different classes and files, and to get the most out of code completion and the code templates.

Chapter 5: One of the strong points of Aptana RadRails is the great support for the client-side of your application: JavaScript, HTML, and CSS. In this chapter you will learn how to write Rails views mixing together Ruby code with HTML or JavaScript and getting assistance for all of the languages.

Chapter 6: When an application grows large, it's always a good idea to have a way of debugging the potential errors. This chapter will show you how to use RadRails' built-in debugger for interacting with your code at run time. You will learn to start a server or a stand-alone script in debug mode, how to set breakpoints , and how to intercept any Ruby exceptions. The debugger will also allow you to walk through your code, to examine the values of any variables and expressions, and even to execute arbitrary code at run time by using the Display view.

Chapter 7: Apart from the coding and debugging, Aptana RadRails provides a number of specialized tools to make the development and management of your application easier. In the context of Eclipse, each of these tools is called a View. In this chapter, you will learn how to use the different views to browse the Ruby and Rails documentation, manage and monitor your servers, install gems and plugins, launch generators and rake tasks, use code annotations, keep track of warnings and to-do lists, evaluate regular expressions, and run your tests. If you prefer to use the command line, then you will learn how to take advantage of the built-in Rails Shell, in which you can get auto-completion for the most used Ruby and Rails commands directly at the command line. This chapter will also show you how to use your IDE to control external servers such as Apache or MySQL.

Chapter 8: Out of the box, Aptana RadRails provides a fully working environment. However, many of its components allow for some configuration. This chapter is a complete reference to all the preferences you can set to change the user experience when using RadRails.

Chapter 9: Aptana RadRails bundles together plenty of interesting features for the developer. However, since the focus is on Ruby on Rails, there are some general aspects of the development of a project that are not covered by RadRails. Fortunately, since the underlying platform is the Eclipse IDE, we have a virtually unlimited number of complementary plugins to choose from. This chapter will give you a general overview of the Eclipse plugins ecosystem, and will also explain in detail how to use two of the plugins you might want to use when developing. DBViewer is a plugin you can use to connect to your database from the IDE. This chapter will show you how to set up the plugin, and how to use it for examining and modifying your database structure and contents. Subclipse is a plugin to connect to Subversion repositories. By using Subclipse you will have repository access directly from your IDE. Besides, the built-in features of Subclipse will help you examine and merge changes in a much more comfortable way than using the Subversion command line.

What You Need for This Book

In order to install Aptana RadRails, you will need the following:

Java Virtual Machine (version 1.5 or higher), preferably the Sun JVM is preferred.RubyRuby on Rails (version 2.0 or higher)The database of your choice, with the proper Ruby gems to establish a connection from Ruby on RailsConnection to the Internet to download/install the different components

As a part of the installation process, Aptana RadRails will automatically guide you through the installation of Ruby and Ruby on Rails if they are not available in your system. You will have to manually install at least a JVM and the database manager of your choice.

Even though the installation of all the required components is out of the scope of this book, you will find in chapter number one a quick guide to installing the JVM, Ruby and Ruby on Rails. This reference has been included for completeness and it's not intended to be exhaustive.

Who This Book Is For

This book is for Ruby on Rails developers who want to make the most of the framework by using an Integrated Development Environment.

Even though the book explains everything you need to follow the contents, the focus is on how to use the tool and not on the Rails framework itself, so previous working knowledge of Rails is highly advisable. Previous knowledge of Eclipse is not necessary.

Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text are shown as follows: "RadRails would allow me to introduce the ModelName, the first_field, and the second_field".

A block of code will be set as follows:

begin ${cursor} ${line_selection} end

Any command-line input and output is written as follows:

\dev\ruby186\bin\mongrel_rails start --port 3100 -o 1

New terms and important words are introduced in a bold-type font. Words that you see on the screen, in menus or dialog boxes for example, appear in our text like this: "Take your time and when you are ready for the installation select the option Go to Workbench".

Note

Important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader Feedback

Feedback from our readers is always welcome. Let us know what you think about this book, what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply drop an email to <[email protected]>, making sure to mention the book title in the subject of your message.

If there is a book that you need and would like to see us publish, please send us a note in the SUGGEST A TITLE form on www.packtpub.com or email <[email protected]>.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.

Customer Support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the Example Code for the Book

Visit http://www.packtpub.com/files/code/3988_Code.zip to directly download the example code.

The downloadable files contain instructions on how to use them.

Errata

Although we have taken every care to ensure the accuracy of our contents, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in text or code—we would be grateful if you would report this to us. By doing this you can save other readers from frustration, and help to improve subsequent versions of this book. If you find any errata, report them by visiting http://www.packtpub.com/support, selecting your book, clicking on the let us know link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata added to the list of existing errata. The existing errata can be viewed by selecting your title from http://www.packtpub.com/support.

Questions

You can contact us at <[email protected]> if you are having a problem with some aspect of the book, and we will do our best to address it.

Chapter 1. Getting Started

You already know how productive, addictive, and fun Ruby on Rails development can be. Yet you often find yourself using the command line, navigating through your source files to find method definitions or references, debugging by printing to the logs, going to the shell for launching or stopping your servers, and basically changing context many times as you are working.

Not to be picky, but when I work with Java or C++ I can navigate my source files just by clicking on the variables or the method names, I can debug step by step in a graphical environment, and I get refactoring and code completion too. I can also control my servers, databases, log files, and everything from a single tool. No command line, no context change.

Now wait a second, am I telling you that working with Java or C++ can be more fun, more productive, or more comfortable than doing it with Rails? No way! You have come to the right place for taking your love for Rails a step further. You are going to learn how to use a solid, enterprise-proven tool for your Ruby on Rails development.

Do I Need an IDE for Rails Development?

First of all, let's see what an IDE is. The name stands for Integrated Development Environment, meaning that you can access most of the ordinary development tasks from a single interface. This is very convenient because you don't need to start several applications, or learn different interfaces when you are working in your projects. Once you know your way around your IDE, even new functionalities look familiar since they all are a part of the same tool.

If you've been programming in static languages like C, C++, or Java you already know there are several mandatory steps in order to get something working. You don't only need to write the code, but also to compile it, link and make it executable, or maybe package it, and if you are using some framework with lots of configuration then you have, in addition, to deal with all those files. And don't get me started about deploying to your own development server. In these cases, the advantage is so obvious that it's a no-brainer to go for a tool in which the whole process from coding to executing is (almost) transparent. That's why even such primitive tools as TurboPascal or TurboC were so appreciated as they saved you a lot of repetitive key punching.

Now when it comes to dynamic languages, and more specifically to Rails, the development cycle is much shorter. You write the code and unless you are changing some non-reloadable file you can directly test your results in your browser. No compiling, linking, packaging, or deploying. Apparently it would seem that an IDE is not such a good idea here.

Now-a-days IDEs provide much more than a simple task automation. They are really helpers that can auto-complete your code, format it, hint about possible errors even as you are typing the source code, assist in refactoring, and integrate with several other tools. Even if Rails is such a comfortable framework by itself, certainly it could use some of these capabilities.

It has also been said that code assist is not so good with dynamic languages. Since you cannot infer the types statically before execution, it would seem almost impossible to get auto-completion or source navigation by linking on the variables and methods. Well, there is some truth in that. Certainly statically typed languages are much easier to deal with for those matters, and the support for these operations is still not as good in Ruby as it is in, for example, Java or C. However, since the first IDE for Ruby made it to the public, the techniques for dealing with code assist have improved greatly and are now very close to those of other languages.

Working with an IDE is pretty different than doing it with a power editor. Of course a good programmers' editor can make development much more comfortable than using a plaintext editor with no macros or highlighting, but when it comes to more sophisticated tasks, they are limited by the amount of logic that you can embed in them.

Nevertheless, it's not a secret that the whole core team of Rails doesn't use an IDE, but a pretty good power editor, so you really don't need an IDE for Rails development; but if you use one, you are going to find yourself dedicating less time to routine tasks and concentrating on the creative and productive part, which is what Agile Development is about.

About Aptana RadRails

Currently, there are several options to choose from if you are looking for a Rails IDE. One of the reasons I like Aptana RadRails the best is because it's built on top of Eclipse. Eclipse (http://www.eclipse.org) is a multi-platform, multi-language, well-tested, enterprise-ready IDE with a lot of plugins for extending its capabilities. It was initially developed by IBM and then released as an Open Source project, being since then a total success.

RadRails was initially started by the middle of 2005 by Matt Kent, Kyle Shank, and Marc Baumbach, who were at the time working for IBM Rational. The RadRails project was built upon the Ruby Development Tools—RDT—plugin, which already supported pure Ruby, but not Rails, development on Eclipse.

After more than a year, part of the core team started their own company, not being able to dedicate enough time to working in the plugin. This was made public in some mailing lists and blogs, causing the community of RadRails users to worry about the future of the IDE. Fortunately the project finally found the support of another company, Aptana, to take over the development of the tool.

Aptana already had a very good Eclipse plugin for JavaScript development, so it had the knowledge and resources to give continuity to the project. Not only that, but Aptana also contacted Chris Williams, the lead developer for over three years of the Ruby Development Tools project, and offered him the opportunity to join Aptana and work full-time on both plugins.

Since Aptana took charge, the plugin has been integrated with the Aptana editors and a number of improvements have been made. Now the plugin is available both in Professional and Community Editions, and it's still an Open Source project, with the lead developer being Christopher Williams. Since the integration, the official name of the project is Aptana RadRails.

To me, this story illustrates an important point. When working with Open Source tools, even when the original team cannot continue the development, it's possible for the community to enjoy the benefits of the tool and to have new releases coming. This is another reason why I prefer RadRails over some other Rails IDE.

If by now you have been browsing Aptana's website (http://www.aptana.com), you will have realized Aptana RadRails comes in two different flavors: as a stand-alone IDE or as an Eclipse plugin. The stand-alone edition also installs Eclipse behind the scenes, but some of the Eclipse functionalities like some start-up arguments will not be available if you choose this option. Also, if you are planning to install external plugins, it's probably better to use the standard Eclipse installation and then install Aptana RadRails on top of that.

How Can Aptana RadRails Help Me?

One thing you have to remember is when we are installing RadRails we will not only be able to use the capabilities of Aptana RadRails, which are indeed impressive enough, but also those of Eclipse and the whole ecosystem of plugins available. I have been using Eclipse for working with Java, PHP, C, and for the last two years, almost exclusively for Ruby on Rails. Here is a list of some of the things that I do on a regular basis from my Eclipse plus Aptana RadRails workbench:

Edit different types of files with syntax highlighting, code assist, code completion, formatting, and error checks. You can edit your Ruby or Rails source code, but also HTML, JavaScript, CSS, YAML, or XML.When working on Rails views, the tool is smart enough to know the context in which I am and give me Ruby, HTML, or JavaScript support accordingly. As an example, CSS support not only provides code assist, but also tells me if a given style element is supported only by some browsers.Navigate from the code of the view to that of the controller or the model with a keystroke, mark occurrences of any variable with a single click, or go to a class or method definition just by clicking over the source code.Use Ruby or Rails command-line tools from a graphic environment. I can run rake tasks, code generators, or tests. I can also install, remove, or update Rails plugins and Ruby gems.Manage my database. There are many different plugins to help you work against your database, and many of them are vendor independent, so you can work with different DBMS.Start or stop servers and monitor their output. At the moment of writing this book there is support for Webrick and Mongrel servers. JRuby can also be used, but it is not yet integrated and requires some hacking.Tail several log files directly from a tabbed window in the workbench.Use the Rails console in an integrated window. One of my favorite features of Rails is going to the console to test pieces of code before putting them into my source files. It's very convenient that I can just copy and paste or drag the selection between windows in the workbench for this purpose.Browse the different API documentation. Not only Ruby core, Ruby Standard Library, or Rails docs, but also a JavaScript reference, for example.Version control: I can work with my repository, create or download projects, modify them, compare my local copy against the version in the repository, and any other functionality your version control software supports in a graphic and consistent manner. I have used it with CVS, Subversion, Perforce, and Visual Source Safe, but the list of available plugins is larger.Bug Tracking: You can use different bug trackers and have them integrated with Eclipse, so you can directly get the bug report, modify the code, update it in the repository, and close the bug report from the same workbench. I have been using it exclusively with Trac, but support for Bugzilla and custom trackers is also built-in.Write and test regular expressions.Keep track of problems and To-Do tasks in my projects.Debug my applications graphically. I can set breakpoints just by clicking on a line, then go step by step, or step into or over the code and watching the different values at run time.

Even if the list above is cool enough, there are more things you can do with Aptana RadRails, so let's see what you need in order to install the IDE and start enjoying it at once.

Prerequisites

This is not a book about learning the Ruby language or the Rails framework, but about how to take advantage of Aptana RadRails to help you develop Rails applications. You should already have working knowledge of Rails and you should have your system set up for Rails development, or at least feel comfortable with the steps involved in doing so. Also, in order to install the Eclipse IDE, a Java Virtual Machine (JVM) will be mandatory.

Even if it is not the purpose of this book to provide exhaustive instructions on the Ruby or Rails and JVM installation processes, you can find below some guidelines on how to set up your system in case you are starting from scratch. Be sure you have all the necessary items properly installed in your system before proceeding to Eclipse and RadRails installation.

Java Virtual Machine

As you already know by now, RadRails is built on top of the Eclipse IDE. One of the features of Eclipse is its portability, which is possible by using Java behind the scenes. This means you will need a Java Virtual Machine (JVM) installed in order for Eclipse to work.

Chances are you already have at least a JVM installed in your system, but you have to make sure you are using version 1.5 or higher, since Aptana RadRails will not work with previous releases. Also, some users have reported intermittent crashes, slower performance, and a higher memory footprint when using a JVM other than that of Sun, so in order to avoid potential problems, it's highly recommended to use the official Sun Java Virtual Machine.

However, Eclipse can run on older versions of the JVM, and if for any reason you cannot install a JVM later than 1.4, then you could still use an old version of RadRails. RadRails 0.7.2 also known as RadRails Classic was the last release before Aptana took control of the development, and it's still available for download. You should be aware there is no official support for it and there are a lot of new features and bug fixes in the next releases. If you install RadRails Classic, you will not find many of the options that we will be discussing in this book.

A typical Java installation will include the executable 'java' in the path of your system/user, so if you are not sure if it is installed in your system or what version you have you can check it by executing the following line at a command prompt:

java -version

This should produce an output similar to:

$ java -version

java version "1.5.0_05"

Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_05-b05)

Java HotSpot(TM) Client VM (build 1.5.0_05-b05, mixed mode)

If you don't have any JVM or your version is prior to 1.5, you should install one before trying to install Eclipse. Since we are not talking about developing Java applications, a minimal set up will do and installing the Java Runtime Environment will suffice our purposes.

Linux and Windows users can get the package directly from Sun at http://java.sun.com/javase/downloads. Mac users can get the appropriate software from http://developer.apple.com/java.

Ruby and Rails

RadRails uses Ruby and Rails in the background for many of its functionalities. For this reason, when you install RadRails, the plugin will try to find Ruby and Rails in your system. If they are already installed and the plugin finds them, it will self-configure properly.

In case Ruby or Rails are installed, but they are not at the default locations, RadRails will offer you the possibility of entering the location of the executables in your system.

If you have Ruby installed in your system but you don't have Rails, RadRails will assist you in downloading and installing Rails automatically.

If you don't have Ruby or Rails installed, then RadRails will take you to the download location but you will have to finish the process of installing Ruby manually.

You can find below a quick reference in case you need to manually install Ruby or Rails.

Components to Install

The basic components of a typical Rails installation are Ruby (together with RDoc and ri for browsing the API documentation), RubyGems, Rails, and the database adaptor of your choice (Rails includes a non-optimized version of a MySQL adaptor out of the box).

Ruby and RubyGems can be obtained as source code or as a binary package for your system, the second option being much handier since you don't need to mess with the internals of the compilation; but of course it gives you less control over the installation.

For the typical user, a binary package should be good enough, and if you are as lazy as I am, you will find it much more convenient than dealing with a full setup from the source. A bit further in this section you can find some options for installing a binary package depending on your OS.

Whether you decide to use the fast track and go for a binary distribution or walk the path of the glory reserved for the brave by compiling from the source, you will find an excellent starting point at the official download site of the Ruby language (http://www.ruby-lang.org/en/downloads/). There you will find the source code and some pointers as how to compile it and where to find up-to-date binary distributions for your environment.

Now let's make a quick tour of the options available for getting up and running with Rails in each of the Operating Systems.

Installing Rails if you already have Ruby and RubyGems

If Ruby is already installed in your system, then there is no need for you to install the whole binary package, unless you prefer so, and you could directly install Rails on top of your current Ruby setup. If Ruby is not installed in your system, you can skip this entry and find the detailed instructions for your particular OS later in this chapter.

If you are running Linux or OS-X, chances are you already have Ruby as a part of your distribution. No version of Windows, at least not yet, comes with Ruby bundled, but of course you will have it already if you have installed it in the past for developing pure Ruby (not Rails) scripts. You can check if Ruby is installed by opening a command prompt and running:

ruby - v

If Ruby is installed (and in the path), you should be seeing something like

$ ruby -v

ruby 1.8.6 (2007-09-24 patchlevel 111) [i386-linux]

Just take into account that some distributions could be using a fairly old release and you will need at least Ruby 1.8.4 for running Rails.

Apart from Ruby, you will need RubyGems in your system before you can install Rails. RubyGems is a very popular package manager for the Ruby language, making the installation of new packages very easy. In most Ruby installations RubyGems will be already present without any further steps. To check if it's installed in your system, you can open a command prompt and type:

gem v

If you get a positive response, then you can directly go and install Rails. In case you don't have it, you can get it from http://rubyforge.org/projects/rubygems. The installation package is just a ZIP file. You will find detailed instructions on how to install it inside, but it should be as easy as unzipping the contents of the package and executing from the command prompt:

ruby setup.rb