Your First Application in Aptana RadRails

0
130
6 min read

Here we are! programming in a powerful language specially designed for the Web and using an IDE that promises to help us with many of the mechanical tasks involved in the coding.

If you have been already programming with Rails, you probably know that if we take advantage of scaffolding we can have a simple web application for table maintenance in a matter of minutes (yes/no typo here, it really takes just a few minutes). And we are even talking about the database table creation process.

If we wanted to add validations, a nice design, and some more complexity we would be talking about a few hours. Still pretty impressive, depending from which programming language (or framework) you are coming.

The truth is, creating the wireframe of your application in Rails is quick and easy enough even from the command line, but we’ll be learning in this article how to do it a bit more comfortably by using RadRails for creating your models, controllers, database migrations, and for starting your server and test your application.

Basic Views

Most of the time when working with our IDE we will be using the Editor Area. Apart from that, two of the views we will be working with more frequently are the Ruby Explorer—the enhanced equivalent of the Rails Navigator, if you were using RadRails Classic—and the Console.

Both of these views are fairly easy to use, but since they will be present at almost every point of the development process, it’s interesting to get familiar with them from the beginning.

The Ruby Explorer View

If you have already opened the Rails perspective, then you should be seeing the Ruby Explorer at the left of your workbench.

Your First Application in Aptana RadRails

This view looks like a file-tree pane. At the root level, you will find a folder for each of the projects in your workspace. By clicking on the icon to the left of the project name, you will unfold its files and folders. The Ruby files can be expanded too, displaying the modules, classes, variables, and methods defined in the selected file. By clicking on any of these elements you will be taken directly to the line in which it is defined.

Before navigating through the contents of a project, we have to open it. Just right-click on its name and choose Open Project.

When opening a project, Eclipse will ask you if you want to open the referenced projects. By default, your projects don’t have any references and that’s the most common scenario when working with a Rails application.

Your First Application in Aptana RadRails

If you want, you can include references to other projects on the workspace so you can open and close them together. To view and change the project references, you can right-click on the project name, then select Properties. Notice you can also get here from the Project menu by selecting Properties. In the properties dialog, you have to select Project References. Here you will see a list of all the available projects in the workspace. Just check or uncheck all the projects you want to reference.

Your First Application in Aptana RadRails

Once your project is open, the mechanism for navigating the contents is pretty straightforward. You can open or close any sub-folders and you can right-click on any item to get a context menu. From this menu you can perform common file operations like creating, renaming, or deleting a file.

We will see more details about creating new files when talking about the Editor Area. There is also a Properties option from where you can change the encoding for a particular file, or the file attributes (read only, for example). The Properties option is also available at the project level.

Your First Application in Aptana RadRails

Also in the context menu, you can see there is a Tail option. This will work like the tail command in UNIX, displaying the contents of a file as it’s changing. This option is especially useful for a quick monitoring of the log files of your application.

You can also find in the context menu two options with the names Compare With and Replace With. If you select either of them, you will see a new menu in which there is an option named Local history. This functionality is really interesting. You can compare your current version against an older version of the same file, or you could replace the contents with a previous one. This can be a life-saver because when using it on a folder the local history will contain copies even of deleted files.

Your First Application in Aptana RadRails

Comparing a file against another copy is a powerful tool, which can also be used when working with repositories or to compare different files between them. Let’s try it and see how it works.

Open any of the files in your project tree by double-clicking on the file name. Now go to the Editor Area and add some lines with Mumbo-Jumbo text. After you are done, click on the save icon of the toolbar or select Save in the File menu. Now let’s go back to the Ruby Explorer, double-click on the file name and select Compare With | Local History.

You will see there are some entries here, one for each time we saved the file. If this was the first time you worked with the file, then there will be only two versions, the original and the one you just saved. Double-click on the oldest local version you have.

Your First Application in Aptana RadRails

Now a new editor will be opened. The editor is divided into three panes, the top one displaying structural differences, the bottom-left one with the code of the current version, and the bottom-right one with the old version of the code.

At the top pane, you will see the structural differences between the versions being compared. For every added or deleted method or variable—at instance or class level, you will see the name of the element with an icon displaying a plus or a minus sign. If a method exists in both versions, but its content was changed, the name will be displayed without any additional icons.

Your First Application in Aptana RadRails

When reviewing the differences/changes you will see the editors at both sides are linked with a line representing the parts that are not equal between the files. When you are on a given change/difference you can select the icon for ‘copying current change from right to left‘ (or the other way round, depending in which of the files the change is), which will override the contents of the left editor with those of the right. You can also just manually edit or copy/paste in your editor as usual.

There is an interesting icon labeled ‘Copy all non-conflicting changes from right to left‘ that will do exactly as it promises. Any changes that can be automatically merged, will be incorporated to your editor. Depending on the differences between the files, the icon could be the contrary ‘Copy all non-conflicting changes from left to right‘.

When you finish comparing or modifying your current editor, remember to save the contents of the editor in order to keep your changes.

If you just wanted to review the changes without any modifications, you can directly scroll down the editors, use the ‘Previous‘ or ‘Next’ icons, or use the quick marks by the right margin.

Your First Application in Aptana RadRails

You can also compare two files instead of comparing a file against an older version. Go to the Ruby Explorer and select one of the files, then hold down the control key and select another one. With both files selected, you right-click and select Compare With and then Each Other. Once opened, the compare editor works exactly the same as when comparing with an old version of the same file.

LEAVE A REPLY

Please enter your comment!
Please enter your name here