Everything

Kabisa, RailsConf Europe and Ariejan.net

Hello there! Just a quick post to let you know I’m still alive and kicking! Two weeks ago I started my job at Kabisa and I’ve been very busy with that. I really like working at Kabisa and we have some great things planned for the near future. (We’re currently working on a few client projects that need our attention.) I’d also like to let you know that I’ll be attending RailsConf Europe 2007 this year!

Rails: Nested resource scaffold

In my previous post I told you about the resource scaffold. What you’ll be doing a lot is nesting these resources. Ingredients in recipes, comments on posts, options for products. You name it, you nest it! Since Rails does not automatically nest resources for you, you should do this yourself. This is, with some minor tweaks, really easy to accomplish. In this example I’ll create recipes that have multiple ingredients. I assume you have Rails 1.2.1 installed for this tutorial to work properly.

Updates: Wordpress 2.1, Themes and Social

You can’t really see it, but Ariejan.net has been upgraded to Wordpress 2.1. I’ve been running 2.1 beta’s on a private server for some time now, so there weren’t any surprises during the upgrade. I’ve also updated the theme to something more stylish and sober. Google Ads are less annoying now and merge nicely with the content. I’ve also re-enabled the social bookmark links so you can quickly bookmark articles on Del.icio.us or Digg. Hope you like the new style. Some minor tweaks will be applied the following days where needed. Please let me know your thoughts on ariejan.net!

Why Ruby Rocks - Convince your fellow developers

I often hear questions from my Java and PHP oriented friends about what makes Ruby so great and easy to use. Until today I’ve shown them some of my Rails feats (AJAX Scaffold always amazes people). Now, I came across this 20 minute Ruby introduction. Starting with the basic “Hello World” item, this article show step by step improvements to end up with blocks, objects and all that makes Ruby really worth while.

“Print this page” with Ruby on Rails

You have put a lot of effort into creating a sexy overview of whatever data your application stores and allow your users to manipulate that data through AJAX controls. But, some people just want to print their data. How to go about that? Just printing the page with data is generally not a good idea because it has been optimized for display on a screen. The first step we need to take is adapting our page for printing. Stylesheets are very handy tools for this. Check the following part of the header of my layout:

Rails: Group results by week (using group_by)

The Enumerable class in Rails contains a method named ‘group_by’. This method is pure magic for a developer’s point of view. I’ll give you a simple example that shows the power of group_by. Let’s say you have a table ‘posts’ containing blog posts. Now, you normally show these chronologically a few at a time. Nothing special there. For some special overview page, you want to group your posts by week.

Textmate+Rails: Easy partials for better code

As you may know, I use TextMate for editing Rails code. I’ve just been browsing the Rails bundle today and I came across some very interesting things. Today I’ll tell you about partials. Partials are ERb templates. They are mostly HTML (or RJS or XML or whatever output format you use) and include some embedded Ruby to show actual content. Partials are not linked to a method in a controller, but instead they can be easily rendered through-out your application. TextMate allows you to refactor your application to use partials with almost no effort!

SVN: How often should you commit?

I often hear discussion about how often developers should commit their work to the central repository. Some say that you should only commit when you’re next ‘release’ is ready. Others say that you should commit every change you make in your code. There are even people who say you should commit your changes only at the end of the day. All wrong! There is no such thing as ‘the way’, but there is a thing called best practice and that’s what I want to talk to you about. How often and what should you commit to your Subversion repository.

SVN: Merge a branch with your trunk

When created a TRY-branch a few days back to try some fancy new AJAX technology in my application. Not problems there, so now I want to merge the code in the branch with my trunk. Since I’m a lone hacker, the trunk has not been touched since I created the branch. I have a checked-out working copy of the branch available. Here’s a handy-dandy guide on how to merge your branch code with your trunk.

Show the current SVN revision in your Rails app

I’m current developing a Rails application. I deploy this application to a demonstration server using capistrano. To streamline feedback and bug reporting I want to show the current revision number of the code that’s published on the demo server to show in the footer of every page. First I looked into Subversion keyword expansion, but this is marked as ‘evil’ and it doesn’t meet my requirements. I want to show the latest revision number of the entire repository and not just that of the current file. Luckily for me, I use capistrano. Here’s how I fixed the problem.