Webcam Chat QuickBooks Advice international calling cards international phone cards
JavaBeat Java Books Certifications Certifications Kits Articles Tutorials Tips QNA Book Store Interview Questions SCJP 1.5 SCJP 1.6 SCWCD 5.0 SCBCD 5.0 SCEA SCJA Feeds

Develop Ruby on Rails applications fast using RadRails 1.0 Community Edition

Author : PacktPub
Topic : ruby books 
Pages :
Submit Your Blog Feedback Request Article Print Email

Title : Develop Ruby on Rails applications fast using RadRails 1.0 Community Edition
Publisher : PacktPub
Topic : ruby
Related : Hibernate, Spring, Struts, ejb
Javabeat : Tips, Java / J2EE Tutorials, Certifications

Aptana RadRails: An IDE for Rails Development

Develop Ruby on Rails applications fast using RadRails 1.0 Community Edition

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 clientside 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.

RadRails Views

By now you should be comfortable with the general interface of Eclipse and RadRails. You know already how to create Rails projects, write and debug Ruby code and views, and work with HTML, JavaScript, and CSS files. We could say most of our programming needs are fulfilled with that.

When developing a Rails project, there are more things to do than the source code itself. We have to start, stop, and monitor our servers, generate code templates, run our test suites, install plugins and gems, generate documentation, keep control of to-do items, or run Rake tasks for different purposes—database migrations, for example.

RadRails provides different views for supporting these tasks that are a part of the development but not of the coding itself. And, of course, it does it so we can control everything from within the IDE without having to go back to the command-line interface.

We already had a glimpse of some of these features when using the Generators, Rake, or Servers views briefl y when we needed them in previous chapters. Now you will learn how to take full advantage of all the RadRails views, to help you take care of routine processes and just focus on getting things done.

Opening the RadRails Views

Some of the views that we will go through in this chapter are available as part of the Rails default perspective, which means you don't need to do anything special to open them; they will appear as tabbed views in a pane at the bottom of your workbench. Just look for the tab name of the view you want to see and click on it to make it visible.

However, there are some views that are not opened by default, or maybe you closed them at some point accidentally, or maybe you changed to the Debug perspective and you want to display some of the RadRails views there. When you need to open a view whose tab is not displaying, you can go to the Window menu, and select the Show View option.

If you are in the Rails perspective, all the available views will be displayed in that menu, as you can see in the screenshot above. When opening this menu from a different perspective, you will not see the RadRails views here, but you can select Other... as we did in previous chapters. If this is the case, in the Show View dialog, most of the views will appear under the Ruby category, except for the Generators, Rails API, and Rake Tasks views, which are located under Rails.

Documentation Views

As happens with any modern programming language, Ruby has an extensive API. There are lots of libraries and classes and even with Ruby being an intuitive language with a neat consistent API, often we need to read the documentation.

As you probably know, Ruby provides a standard documentation format called RDoc, which uses the comments in the source code to generate documentation. We can access this RDoc documentation in different ways, mainly in HTML format through a browser or by using the command-line tool RI. This produces a plain-text output directly at the command shell, in a similar way to the man command in a UNIX system.

RadRails doesn't add any new functionalities to the built-in documentation, but provides some convenient views so we can explore it without losing the context of our project's source.

Ruby Interactive (RI) View

This view provides a fast and comfortable way of browsing the local documentation in the same way as you would use RI from the command line.

You can look either for a class or a method name. Just start typing at the input box at the top left corner of the view and the list below will display the matching entries. That's a nice improvement over the command line interface, since you can see the results as you type instead of having to run a complete search every time.

If you know the name of both the class and the method you are looking for, then you can write them using the hash (pound) sign as a separator. For example, to get the documentation for the sum method of the class Enumerable you would write Enumerable#sum.

The documentation will display in the right pane, with a convenient highlighting of the referenced methods and classes. Even if the search results of RI don't look very attractive compared to the output of the HTML-based documentation views, RI has the advantage of searching locally on your computer, so you can use it even when working off-line.

Submit Your Blog Feedback Request Article Print Email

Related Articles


JavaBeat Website (2004-2011), India
javabeat | advertise | about us | contact | useful resources
Copyright (2004 - 2011), JavaBeat


Technology Blogs
Technology blogs Technology Blogs
blog log