We felt lucky, the 20 of us from Copenhagen Ruby Brigade who had taken the time to show up for the third gathering of Rails enthusiasts in and near Copenhagen, this time hosted at my company; Kraftvaerk. Not only had open source guru and Ruby for Rails author David Black decided to join us for the evening, having taught a workshop in Malmö two days before; but when a little later no other than our own Rails creator and community front figure David Heinemeier Hansson (DHH) stepped in through the door, we started wondering whether this was really just a humble user group meeting – or RailsConf Copenhagen!
Not only did DHH willingly answer all questions we could come up with, he also showed us his demo from his keynote at RailsConf in London, including some pieces that hadn’t been ready for the conference, and which we were probably the first to experience. It’s hard to take notes of guy writing code live on the screen, especially when he moves away from the planned demonstration into “I’ve never tried this before, but let’s see if it works!”, but I tried, and this article is my write-up of DHH’s answers and demos.
HAML
DHH gave a quick sample of HAML – HTML Abstraction Markup Language – a template language for rendering beautiful XHTML in an easy to read and write way, created and announced by Hampton Catlin at RailConf Europe 2006, and quickly acknowledged by DHH:
%html %body #person #details .phone_numbers %li = list_of(:people) &:names
What’s cool about HAML, DHH said, was that it kept you DRY, even when you are writing HTML. The % is used for normal tags, the # creates div tags with the given id and the . creates div tags with the given class. It’s even possible to mix in Ruby code and for example create a list.
Internationalization
Being in a room full of Danish programmers, it was only that natural that internationalization came up – especially since Jesper Rønn-Jensen has been working on a localization plugin, and as Morten Christensen pointed out; shouldn’t 5 or more plugins for internationalization indicate quite clearly that the Rails community craves unified support implemented in the core?
No, DHH answered, from the Core Team’s point of view, this means that people want to support and implement internationalization in a lot of different ways, and that there is no universal solution that will make everybody happy. Even inside the Core Team people can’t agree how it should be done. Although, DHH added, I can’t rule out that the 37signals needs internationalization, is the day that Rails get it.
Better scaffolding
Scaffolding has lured a lot of developers into the wonders of Rails, but really, DHH said, it has always had a lot of strange limitations, which made it nearly useless for doing any real stuff. Scaffolding continues to be primarily a teaching tool, but the new scaffold_ressource command makes a lot of things right, that was wrong in the old kind of scaffolding:
In summary; the new scaffolding generator lets you create RESTful scaffoldings that you can actually build on top of, and all with a command like this:
./script/generate scaffold_ressource post title:string created_at:datetime body:text
Any action can respond in any kind of format
By adhering to the Simply RESTful conventions and using the respond_to method, we can make our objects in any format we desire, without having to write separate actions for each format. DHH was building up his classic weblog application, and wanted to implement an XML representation of the Post object that could be consumed by an external application:
def index
@posts = Posts.find(:all)
respond_to do |format|
format.html
format.xml { render :xml => @posts.to_xml }
end
end
This code actually enables us to access the list of all posts in the ordinary RHTML format from the url /posts, but if we want the XML representation of the same list, we just add .xml; like this: /posts.xml. This doesn’t just work with XML, in fact it works with any kind of extension you add support for in your actions, as long as you also remember to add it’s mime type in environment.rb, as DHH had to do to support the CSV format:
# environment.rb
Mime::Type.register("text/csv")
Further, DHH recommended his plugin Resource Feeder for easy support of ie. RSS using the method render_rss_feed. Another cool thing added is the auto_discovery_link_tag method, which renders the appropriate tag to ensure that the RSS icon is shown in Firefox, Safari and IE7.
ActiveResource working like a charm
While no surprise to all the lucky ones that attended RailsConf Europe, I enjoyed seeing the visions for ActiveResource DHH explained at the conference in Chicago, being now brought to life and working like a charm. By letting a model inherit from ActiveResource::Base instead of ActionRecord::Base and giving it a url to feed of, DHH demonstrated that you can treat objects in an external API exactly like the ones in your own database. And not just reading part of CRUD, the whole package. Sweet!
If you are in Copenhagen or southern Sweden (or are willing to travel), you have a great chance to attend a free Ruby on Rails on workshop with the acknowledged Ruby expert, Rails writer and RailsConf organizer David Black this Sunday; September 17th, at 10.00-18.00 in Malmö, Sweden.
It’s the Swedish startup Polar Rose that are hosting the workshop, both to educate its own people in Rails technology, but also to get in touch with the Rails community in the region of Øresund. Nikolaj Nyholm, the CEO of Polar Rose and program chair for O’Reilly EuroOSCON, originally tried engaging David Black for a tutorial at EuroOSCON. David Black was however busy with a workshop in Amsterdam, but when that was cancelled, David was quickly redirected to Malmö.
In other news, Kraftvaerk, the company I work for, are hosting the next Copenhagen.rb gathering at Thuesday September 19th, and rumour has it that David Black might also attend this event, if he can fit it into his busy schedule – my fingers are crossed! :)

David Black (left) with Chad Fowler photographed at RailsConf 2006 by yours truly
It’s official. I’ve bought a Mac. I have never used a Mac before, and I am actually enjoying the discovery process I have to go through to get up to speed on this new platform. (Example: While writing this first paragraph, I figured out – by trial and error – that you select words in chunks with Shift+Option, not Shift+Ctrl like on Windows.)
I’ve already had several small victories in the process of customizing OS X to my needs, and since Google Analytics reports that one third of you readers are on a Mac, I’d like to share a quick tip with you. One of my main reasons to switch to Mac is the availability of the terminal; which unleashes the power of the Darwin system behind the fancy GUI. I had half expected the visual aspects of this terminal to be highly configurable, and while some options exists, it wasn’t immediately possible to get the terminal to slide down in a cool Quake-style console way like I had dreamed of for a while.
So I set out to find a way to do this, and through this forum thread I found out that I was not the only Mac user with this strange need. Some of the clever geeks taking part in the thread has been so nice as to actually write a small application that enables the terminal to slide down; called Visor. I’m quite impressed with OS X being flexible enough to provide this kind of extensibility.
The installation is quite easy – just follow the instructions and make sure you have OS 10.4 – but one thing caught me, being a complete Mac newbie, as a small frustration: I didn’t know to look for the Visor icon (which is a small black terminal) next to the clock in the upper right corner. You must configure Visor using this menu (which will appear when you (re)start Terminal after following the instructions) before the terminal is able to slide down using your selected hot key.
As a final touch I’ve also opted to make the terminal semi-transparent and added some eye candy as a background image. You do this by opening a normal shell window in Terminal, make your settings in Window Settings > Colors and restarting Terminal. Visor also supports animated backgrounds, but I haven’t tried that out.

While I’m quite happy with Visor, I still have my doubts about whether Microsoft Entourage is the right email application for me (as a heavy Outlook user through many years it seemed an obvious choice) and whether Fire is the right instant messenger. One thing that really annoys me, and that I haven’t been able to solve so far, is that OS X automatically puts the computer to sleep when I close the lid. I am aware that various heating issues can occur if it didn’t, but I’m just used to close the lid while the computer is shutting down – this will put it to sleep during the shutdown. If anyone knows of a good solution for this, I’d be happy to hear from you.
Hello, I'm Casper Fabricius. I have developed for the web for 10 years, and have been enjoying Ruby on Rails for the past 5.
My experience covers communities, shopping solutions, multi-language sites, heavy back-end lifting and a wide selection of more traditional websites. I like to integrate Ruby with Java and .NET through JRuby and IronRuby when it makes sense. I am passionate about test- and behavior-driven development, but at the same time I am pragmatic and believe in getting things done.
I live in Copenhagen, Denmark, where I work for a fantastic company: Podio. I do not currently take on freelance assignments.