The Visual Rails Workbench
Well, if you can’t find one, there really is no option but to write one yourself. That, fundamentally, was the impetus behind the creation of my company, SapphireSteel Software, and our Visual Studio-hosted IDE, Ruby In Steel.
Before going on, let me put all my cards on the table. I’ve designed and programmed a fair bit of Ruby In Steel myself and I admit to being totally and utterly biased. Today we launched a new visual design environment for Ruby On Rails but I’m not going to review it here - even I am not that shameless! What I will do is tell you a bit about what we have been doing and why we are so utterly determined to make the darn’ thing visual - a heck of a sight more visual than any other Ruby IDE on the planet.
Ruby programming has, up to now, tended to be a code-centric affair. You write code in an editor then you go to a command prompt and you run the code in an interpreter. I did that whole editor-and-command-prompt thing back in the ‘80s. It’s a style of coding which is now so ancient that, to a new generation of programmers, it seems modern again. But not to me. Having put the command line behind me twenty years ago, I feel not the slightest inclination to go back to it now.
But how do you give a language such as Ruby a really visual makeover? To date, we’ve approached this from several angles. First, we created a cross-language-linking component, The Ruby Connector, which lets .NET programmers write hybrid programs that combine elements of a .NET language such as C#, VB.NET or Chrome with regular Ruby. This also solves the visual interface problem by letting the programmer do all the front-end design in .NET while running Ruby at the back end.
STEP ONE: The Ruby Connector
Hybrid programs like this have their uses but they are still some way short of the complete drag-drop-and-code way of working that is second nature to an old Delphi programmer like me. This part of the equation will eventually be solved when Microsoft releases IronRuby - a .NET implementation of the Ruby language running on the Dynamic language Runtime.
STEP TWO: IronRuby
We’ve already released a free IronRuby version of Ruby in Steel complete with a form designer. Unfortunately, this isn’t production-ready yet since IronRuby itself is still in the alpha stage of development. As IronRuby develops, we will continue to enhance our IronRuby IDE. In the long term, this really could turn into a Ruby alternative to Delphi or VB.
The problems of visual design for Ruby On Rails are rather different. Rails is not used to create desktop applications so the ‘form-design’ way of working is not relevant. Rails is used to create database-driven web applications. It links together the data (the ‘Model’) with the programming logic (the ‘Controller’) and the visual interface (the ‘View’).
By default, Rails Views are defined in sets of template files which contain a mixture of HTML mark-up with Ruby program code. A single web page may be defined by multiple templates - typically comprising at least a Layout (repeating elements such as headers and menus), a View (the elements of a specific page such as data-entry) and one or more ‘Partials’ (items such as submission forms).
The Ruby code in these templates is executed by Rails and multiple templates may be combined to form a single HTML page at runtime. However, at design time, the final layout of the page is not available for the simple reason that, while all those fragmented HTML/Embedded Ruby templates may mean something to Rails, they don’t mean much to a web design tool such as the Visual Studio Designer or Adobe Dreamweaver.
To get around this limitation we have created a visual design environment that lets you work with fully formed HTML pages at design time. In order to do this we have had not only to work out how to combine all the various Rails templates that define a single page but also how to translate embedded Ruby into HTML and back again.
STEP THREE: The Visual Rails Workbench
This has been a far more complex task than we initially anticipated and the environment (the Visual Rails Workbench) has taken about a year to complete. I think it’s been worth the effort though. The end result is that you can now do real drag-and-drop design for Rails: you can drag a control from a toolbar, drop it onto a web page, resize or move it with the mouse and set its properties in the Property panel.
I know there are those people who will think this is the work of the devil and that all good Rails programmers should stick with plain text editors and command prompts. That’s fine. Each to his own. But as far as I am concerned, the more ‘visual’ the better...