I was at the San Jose Tech Museum of Innovation this past Saturday, April 19 to deliver a presentation at the SDForum Third Annual Silicon Valley Ruby Conference. The theme of the conference this year was “Using Ruby and Rails for Innovation and Creativity”. Given this theme, and what I have been involved with in the past several years, I decided to talk about how I have been getting Ruby on Rails applications developed in the enterprise environment.

The main message that I tried to convey in my presentation is that enterprise application development could be fun, when done with Ruby and Rails. Another equally important message is that a very effective way to get Ruby and Rails accepted in the enterprise application landscape is through thoughtful penetration from the skin, down to the core.
The enterprise environment is a complex one, no doubt about it — typically involving more than one operating system platforms, multiple legacy data sources, many existing components and affecting various organizational units. So, why add more noise and complexity to this circumstance? I would prefer dealing with YAML to XML for configuring things, Ruby to Java for spelling magic, and Rails to — heck, I am not even sure what the comparable legacy alternative would be… Struts or Spring plus Hibernate, or servlets and EJBs? — for building applications so I could reduce, rather than add complexity to this environment.
But, Ruby and Rails are not even enterprise ready, right?
Wrong.
If your plan was to conquer the enterprise world — gut the systems, remove all of the legacy stuff, and replace them with Ruby and Rails components — then of course, Ruby and Rails are not nearly ready for that. But there are tons of other things that happen in the Enterprise 2.0 landscape, and Ruby and Rails are the best candidates to be the tools for developing the solution to the problems occurring in this turmoil. These days, we blog, use wikis, tag and share bookmarks, and build social networks regularly outside and inside the enterprise. Business stakeholders start to see the benefits of these activities, and they would like to build applications that can mash up legacy services and can have the features that enable these activities.
This is what I mean by penetrating the enterprise landscape from the skin, down to the core. Rails provides a great framework for orchestrating web services, whether they are SOAP- or REST-based. It enables experienced enterprise developers to be even more competitive — by being able to build better mashup applications at the edge of enterprises at a lower cost, and faster. Rather than aiming to replace enterprise systems, the plan should be to complement them by continuing to take advantage of Rails strongest suit: being the services orchestration platform of choice at the edge of the enterprise. In other words, closer to the skin of the enterprise architecture. Over time, as Ruby and Rails age gracefully and become more mature, it would only be natural to build systems closer to the core of the enterprise architecture with them.
As far as being able to run Ruby and Rails applications on a traditional enterprise platform, I have gotten that done recently on the IBM zSeries mainframes. Well performing, elastic, and scalable applications that are integrated with and stand tall alongside other more traditional enterprise applications. If that is not enterprisey enough, I don’t know what is.

So, last Saturday, I closed my presentation by appealing to the community to be more creative about looking for opportunities to use Ruby and Rails to build edgy Enterprise 2.0 applications.
These past few days I have been greatly occupied with getting into Second Life (SL) for a project that aims to replace some physical collaborative design processes with virtual ones. I have to admit that although I have had an SL avatar on the Linden grid for over a year, I have only logged in and wandered around inworld at most a couple of times and never more — but that has been more because of the lack of available time to explore than the lack of interest. Lucky me, this time I’ve got a chance to do it in the context of a commercial project.
Having been around for about five years, SL is one of the most populated virtual worlds with over 2 million registered users as of January 2007 (and 12 million registered users as of today!). Although the actual percentage of active users is arguable, SL has a healthy virtual economy and community that had produced a real-life millionaire worthy the front page of BusinessWeek and a virtual babe that made it to the list of the Maxim Hot 100. Now, no one can argue with that kind of success, right?

So, to get started, I went ahead and downloaded the latest SL client software from the community downloads page. My laptop is a Lenovo ThinkPad T60 with a 1.83 GHz Intel Core 2 Duo T5600 CPU and 2 GB of RAM running Windows XP, and as it turned out, this machine has enough power to run the client and connect to the grid comfortably. If you do not yet have an avatar, you would need to register and create one through the registration page before running the client software. The registration process is quick, and once completed, you will be able to go inworld immediately with the newly created avatar.
After going through the welcome orientation, one of the first inworld landmarks that you should teleport to is The Shelter, where you could meet other new residents, watch video tutorials, pick up some freebies, and learn a great deal more about the environment. Also, check out the community events calendar to find out what is going on throughout the day. Not to be missed is the official SL blog, where you will find announcements about software updates, blackouts, and other issues.
Welcome to the grid!
This entry has been republished on February 20, 2008 by SYS-CON Media WebSphere Journal online magazine
IBM HTTP Server (IHS) is a derivative of Apache with extensions to support the IBM WebSphere Application Server (WAS). It is different enough that you can’t simply interchange it with the plain Apache if you have to support WAS applications. Nevertheless, it is still an Apache derivative, and therefore it supports Apache modules and extensions and behaves more or less as expected.
Recently, I ran into a requirement to set up a file server on an IBM zSeries mainframe platform running various WAS components and applications. To cut a long story short, this customer requirement eventually translates into having a WebDAV file server set up on existing IHS instances on the mainframe. Well, don’t let the mainframe platform scare you away. This system runs Linux on System z — or zLinux — virtual machines with Novell SUSE Linux Enterprise Server (SLES) as the operating system. From the application and system administrative perspectives, the operating system is just another flavor of 64-bit Linux — not much different from the Intel x86 version of SLES. As a matter of fact, with very little difficulty, I have been able to set up clusters of Ruby on Rails application servers to support a Google Maps Enterprise and ESRI ArcGIS mashup application on this same mainframe platform. But that’s another story that I will have to share with you another time…
So, even though there aren’t many explicit instructions out there on how to set up WebDAV on IHS on zLinux, I was able to do it by following the vanilla instructions for doing the same with Apache, testing the set up on a local Intel-based virtual machine running SLES, and finally implementing the same set up on the target mainframe platform. For your enjoyment, here are the steps that you can follow to replicate what I have done.

To do this, find the main IHS configuration file httpd.conf, which should be located in /opt/IBM/HTTPServer/conf directory, and uncomment the directives that load modules/mod_dav.so and modules/mod_dav_fs.so. Obviously, you will need to have root privileges to be able to do this. Next, add a directive at the end of the configuration file to load httpd-dav.conf which we will create in the next step.
... LoadModule dav_module modules/mod_dav.so LoadModule dav_fs_module modules/mod_dav_fs.so ... Include /opt/IBM/HTTPServer/conf/httpd-dav.conf
Next, you need to create the configuration directives that will enable DAV for the directory on the server that you want to serve. In my case, I had an NFS partition mounted in /files that I wanted to use as the file server storage. In /files, I created a subdirectory called dav that I made readable and writeable to the IHS instance, which runs as user nobody of group nobody. This is the directory where uploaded files and collections — the DAV terminology for folders — will reside. In addition, I had to create a subdirectory to hold the lock files that will be created by the DAV modules, also made readable and writeable to the IHS instance.
# mkdir /files/dav # chown nobody:nobody /files/dav # mkdir -p /opt/IBM/HTTPServer/var/DAVLock # chown nobody:nobody /opt/IBM/HTTPServer/var/DAVLock
The configuration directives for enabling DAV for the /files/dav directory resides in /opt/IBM/HTTPServer/conf/httpd-dav.conf and looks like the following:
DAVLockDB /opt/IBM/HTTPServer/var/DAVLock
DAVMinTimeout 600
Alias /files/ "/files/dav/"
Alias /files "/files/dav"
<Directory "/files/dav">
DAV On
Options +Indexes
AuthType Basic
AuthName "DAVney File Server"
AuthUserFile "/opt/IBM/HTTPServer/conf/user.passwd
AuthGroupFile "/dev/null"
<LimitExcept POST GET>
Require valid-user
</LimitExcept>
</Directory>
To complete the set up, you will need to create the file that will hold the valid DAV users and their hashed password. I did this by using the htpasswd executable that comes with IHS.
# cd /opt/IBM/HTTPServer/conf # ../bin/htpasswd -c user.passwd joe New password: ****** Re-type new password: ****** Adding password for user joe
Finally, you are ready to rock and roll. Restart IHS and use a DAV client to connect to your new DAV file server!
# /opt/IBM/HTTPServer/bin/apachectl restart
If you have access to a Windows XP workstation, open the Internet Explorer web browser, select menu item File > Open, select Open as Web Folder checkbox and type the URL to the DAV file server in the text field, like so: http://joe@<dav_server>:80/files/ — replace <dav_server> with the IP address or name of your DAV server. You can then upload and download files and folders using drag-and-drop actions to and from the DAV file server. There are other freely available WebDAV clients that you can use, such as SkunkDAV, Novell NetDrive, and DAVExplorer. To use these clients, however, you will have to download and install their executables on your Windows XP workstation.
This afternoon, I needed to update my FreeBSD workstation to get to the latest Ruby and Rails versions. This was because my current projects are using later versions of Ruby and Rails than what I had — Ruby 1.8.5 and Rails 1.2.3. As it turned out, since I have been using the FreeBSD ports, it was fairly easy to upgrade Ruby to the latest ports version, 1.8.6.

First, I had to refresh my ports tree:
portsnap fetch && portsnap extract
This step took a good while since I had not refreshed my ports tree for some time. Once it was completed, I needed to install portupgrade and upgrade the applications.
cd /usr/ports/ports-mgmt/portupgrade && make install clean portupgrade -R ruby portupgrade -R ruby18-gems
That step took care of Ruby and RubyGems, getting them to versions 1.8.6 and 0.9.4 respectively. For the Ruby upgrade, don’t enable pthread support, which could otherwise cause incompatibilities with other applications. Upgrading Rails was even easier using RubyGems.
gem update rails --include-dependencies
And that was it, now I am on Rails 1.2.5! I love it when things just work…
In case you missed the announcement, OpenMoko Neo, the Linux mobile phone that comes with an open source development framework, has just gone live and can be bought now for $300.00. That’s dirt-cheap compared to the at&t-locked iPhone that goes for $500.00 to $600.00 a pop and a mandatory 2-year contract.

The Neo 1973 runs totally Free Software. Even hardware-wise we’re pushing things drastically further than most device manufacturers. The Neo was specifically designed with openness and ease of developer-access from very start. ... End user Freedom is our passion. The entire OpenMoko system and application software are built using Free and Open Source Software (FOSS).
Unlike the consumer-oriented Apple iPhone, this gadget is clearly targeted for mobile device hackers. I love it!
It’s easy to install MySQL 5.1.x on FreeBSD 6.2 if you follow these instructions:
cd /usr/ports/databases/mysql51-server make install clean mysql_install_db chown -R mysql:mysql /var/db/mysql/ /usr/local/bin/mysqld_safe -user=mysql & mysqladmin -u root password <password>
And then, optionally:
echo 'mysql_enable="YES"' >> /etc/rc.conf cp /usr/local/share/mysql/my-medium.cnf /var/db/mysql/my.cnf
Why FreeBSD, you may ask… Well, for one, it’s got more smileys than Linux or Windows in this comparison table. For another, the fonts on X — with Xfce 4.4 and X.org X11R6.9 server — are rendered much more legibly on FreeBSD than on Linux. For more opinionated reasons, read this piece and also this article...
My problems with Windows-created text files did not end with this nasty episode. I am still in the process of building the contents of a web application — writing a Ruby script that reads metadata files in a directory structure to feed the backend database with initial, static contents. The metadata are provided as YAML files, created by another team member using Windows Notepad. Simple, enough, don’t you think — no chance for any problems, right?
Wrong.
Murphy could have had Windows in mind when he came up with his law, because even this seemingly simple task of feeding Notepad-created plain text file to my Ruby script had failed miserably. This time, though, I immediately suspected incorrect character encoding as the source of the issue, and I was right.
I won’t bore you with the details of the investigation, but the bottom line is, when you save a text file in Notepad, be sure to have the right character encoding selected. If not, you could end up with a text file with characters encoded in Unicode when what you really want is just plain ASCII. Which was what happened to me, and a gross violation of the principle of least surprise.

Luckily, I do my Ruby and Rails(*) work on Xubuntu Linux, a Debian derivative. And, like most Unix platforms, it’s got iconv installed and ready to use.
iconv -fUnicode -tASCII unicode.txt -o ascii.txt
Very handy. The above command tells iconv to convert and save the Unicode file into plain ASCII.
Update: Another alternative is to use recode, which will perform an in-place update of the characters in the file.
recode windows-1252.. the-file.txt
If you are still developing Ruby and Rails applications under Windows, you should consider switching to a variant of Linux, or OS X. Everything simply works — and works better! — on these platforms, and you will also get the benefit of having access to the native implementation of wonderful GNU tools like iconv.
———
(*) No, that’s not a typo. I do a lot of naked Ruby as well as Ruby on Rails development. And I love doing both!
These are my all time favorites…
Three words: I. WANT. ONE.

More information about this beautiful desk on the product page...
I spent a little bit of unpleasant time yesterday debugging what I thought was a quoting issue with the Rails runner script. Here is what happened.
I wrote a script to populate my development database with some static data — the textual content of a web application. This textual content happens to have quote characters (’) embedded. The script instantiates and saves a number of model objects containing the text.
To make sure that the quotes won’t give me any problems, I issued these on the Rails console, which turned out fine:
Thing.create(:title => "I'm good", ...) Thing.create(:title => "I'm bad", ...)
That is, the title column in the database appeared to have gone through the proper quoting or escaping — done automatically by ActiveRecord, as expected.
However, when I ran the script through the runner, all my quotes appeared as the question mark (?) characters in the database. Could there be a bug in runner? Do I need to escape the quotes manually? What’s going on?
As with all good stories with happy endings, the real problem is really, ... let’s say, stupid.
You see, in the script, I’ve got a lot more text than what I typed on the Rails console. Remember, these are texts to populate sections of a website, so they are more lengthy than just a handful of words. As a matter of fact, I’ve got these texts — cut and pasted these texts, to be exact — from an existing Microsoft Word document. By now, you probably can tell where I’m going with this already…
Well, take a look at the content this file, and see if you can spot the problem right away:
If you have Emacs, open the file and point your cursor to the first instance of the quote character in the file, and then press Ctrl-x =. Try to remember the result of that, and then do the same thing with the second instance.
Surprised? I was, too.
The first quote character in the file appears to be the hexadecimal ‘0×27’, the ASCII representation of the quote character, while the second one the hexadecimal ‘0×92’, the Windows 1252 (CP1252) representation of the curved quote character.

This is what Wikipedia says about this odd mismatch:
It is very common to mislabel text data with the charset label ISO-8859-1, even though the data is really Windows-1252 encoded. In Windows-1252, codes between 0×80 and 0×9F are used for letters and punctuation, whereas they are control codes in ISO-8859-1. Many web browsers and e-mail clients will interpret ISO-8859-1 control codes as Windows-1252 characters in order to accommodate such mislabeling.
Dang it, Dale. I should have known better than to trust Windows with supplying my characters…