Tag Archives: ruby

Emacs and tilde files

By default Emacs saves a copy of the previous version of a file you are editing in the same directory as where the original file is located. It saves a copy with ~ appended to the end of the name. ~ is pronounced tilde. However, some tools and programming environments don’t know how to handle these tilde files and this can cause various problems. Someone mentioned on the Boston Ruby list that “Rails 2.3 router picked up emacs tilde ~ file before *.erb.html file …“. And the solution is pretty easy, you just tell emacs to save the ~ files in a different directory:
http://amitp.blogspot.com/2007/03/emacs-move-autosave-and-backup-files.html

Now I wonder is there a way to have it only do this for certain types of files, or only to do it for certain workspaces, that way if I’m edit a file in a directory named ruby it will save the files elsewhere, otherwise save the file in the CWD.

Rails for Eclipse!

Aha! There is RoR support for Eclipse, via Aptana. I’ve just installed it and the instructions are a bit cryptic. Basically you have to install Aptana first (you can do this as an Eclipse plug-in). Then restart Eclipse and then install the Rails plugin called RadRails. Aptana also has Python and PHP support.

Install Aptana:

In Eclipse click on Help->Software Updates. Then click on the Available Software tab, then click on Add Site and paste this URL into the Dialog Box that opens:
http://update.aptana.com/install/3.2/

Eclipse Aptana Install Dialog
Eclipse Aptana Install Dialog

Install Aptana, then restart Eclipse. Aptana will then prompt you to install the Subversion plugin, then restart.

When Eclipse restarts following the same procedure as above, except add the following site for Rails support:
http://update.aptana.com/install/rails/3.2/

And restart Eclipse. Aptanta may prompt for further plugins, some of which are from their Professional version which will only work for 60 days.

This works with Eclipse 3.4, and should work on 3.3 and 3.2.

IBM shows how to use RadRails:

http://www.ibm.com/developerworks/opensource/library/os-ecl-radrails/

Complete install instructions:

http://ubuntumagnet.com/2008/01/installing-eclipse-radrails-and-subclipse-under-ubuntu-710-gutsy-gibbon

Netbeans 6.5, with Ruby on Rails & JMaki

While writing some RoR code at home (or at least trying to grok the RoR way) I’ve alternating between using Emacs & Netbeans 6.5. Emacs is one true editor to rule them all, but what it’s lacking is code completion such as in Netbeans.

I was working on test RoR project last night with Emacs, and after a couple of hours imported the project into Netbeans 6.1 (a painless process). When I opened the “.erb” file I had been editing in Emacs, I noticed a panel on the right side of Netbeans titled “Palette”, that allows easy creation of html items such as tables & lists. It also, includes JMaki support for Dojo, Yahoo’s YUI, Scriptaculous, Spry, & JQuery, which allows quick and easy insertion of Ajax features using JMaki. After about 5 minutes of mucking around with various Ajax tables, I was easily able to replace a basic HTML table with a prettier, sortable, Yahoo YUI, Dojo, or JQuery tables.

Here’s a rough example, showing the difference between an list, and a sortable Yahoo YUI table created with Netbeans & JMaki:

Sample Tables

This is fairly powerful, and for those inexperienced with Ajax provides a quick and simple way to add Ajax features to a web-page or application as it provides Ruby constructs to create the necessary JavaScript and encapsulates the programmer away from the JavaScript. On the other hand, if your an “ace Ajax guru” this doesn’t allow you to directly write and access JavaScript, and the abstraction might seem like an hindrance.

Here’s a quickie overview showing how to use the JMaki features using a 6.1 beta and Ruby on Rails:

http://blogs.sun.com/arungupta/entry/jmaki_on_rails_reloaded_for

And a more recent generic overview using 6.1 & standard HTML/JSP:

http://www.netbeans.org/kb/docs/web/ajax-jmaki-quickstart.html

What’s also useful, is that JMaki in Netbeans creates the same looking code on your HTML rendering page, which means that if you can create JMaki widgets using Java you can easily do the same with RoR, and presumably with PHP.

If your haven’t looked at Netbeans 6.1 or haven’t tried Netbeans in a while, I do think there are some really useful features that sometime give it the edge over it main competitor Eclipse. I use both IDE’s regularly, and prefer Eclipse for Java & Perl development, but for RoR (especially on Linux) and Ajax features I think Netbeans is the winner (for now). However, there is a JMaki plugin for Eclipse which I haven’t tried that might be comparable (for Java applications).

Using both IDE’s could be a useful addition to a programmer’s toolbox. What I must do next is test Netbeans with a J2EE project created under Eclipse and see if I can use both IDE’s on the same project without problems. It be interesting to see if I can edit the Java code with Eclipse and then modify the view and add JavaScript/Ajax feature with Netbeans.

More information about JMaki can be found at:

https://ajax.dev.java.net/

Updated: Fixed version number, it’s Netbeans 6.5 and not 6.1. Fixed typos from writing tooo fast.

Netbeans 6.5 on Debian

Doesn’t perform badly, I’ve been using it recently with Ruby code, and I like how it colourises the code to make editing code easier, and performs it auto-completion and method lookup (basically all the features you’d expect with a modern IDE).

It’s does’t startup as fast as using Emacs, or vi, but I find the features very handy and very convenient. It doesn’t look  bad either. It runs better on my PC at home running Debian Linux than it does on my PC at work running WinXP. This is probably because I’m using a 1.5 JVM on WinXP and a 1.6 JVM on Debian. Running on 1.6 JVM’s means that Netbeans will automatically use anti-aliased fonts if you have anti-aliased fonts enabled (much easier on the eyes if your using a LCD screen).