Discover millions of ebooks, audiobooks, and so much more with a free trial

From $11.99/month after trial. Cancel anytime.

Aptana RadRails: An IDE for Rails Development
Aptana RadRails: An IDE for Rails Development
Aptana RadRails: An IDE for Rails Development
Ebook459 pages3 hours

Aptana RadRails: An IDE for Rails Development

Rating: 0 out of 5 stars

()

Read preview

About this ebook

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.

LanguageEnglish
Release dateMay 23, 2008
ISBN9781847193995
Aptana RadRails: An IDE for Rails Development

Related to Aptana RadRails

Related ebooks

Information Technology For You

View More

Related articles

Reviews for Aptana RadRails

Rating: 0 out of 5 stars
0 ratings

0 ratings0 reviews

What did you think?

Tap to rate

Review must be at least 10 words

    Book preview

    Aptana RadRails - Ramirez Javier

    (missing alt)

    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.

    Ruby

    Ruby on Rails (version 2.0 or higher)

    The database of your choice, with the proper Ruby gems to establish a connection from Ruby on Rails

    Connection 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

    Enjoying the preview?
    Page 1 of 1