Archive for December, 2006

Textmate+Rails: Easy partials for better code

December 22nd, 2006

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?

December 20th, 2006

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

December 20th, 2006

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

December 13th, 2006

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.

Announcing “Subversion Kick-Start”

December 11th, 2006

With this post I officially announce my first book, “Subversion Kick-Start“.

Subversion is a popular version control system that’s used by many, many developers around the globe. Most developers know how to find their way around Subversion, but quite a lot do not.

SKS is for every software engineer who wants to learn how to put Subverstion to real use for their projects. It’s more than just storing code. It’s about structuring the way you write code. It’s about optimizing the way you work.

Subversion Kick-Start is aimed at getting you and Subversion up and running as quickly as possible with the minimal amount of effort required.

Please subscribe to my feed newsletter or RSS feed and stay up-to-date! You’ll be the first to know when the book is available.

Install ruby-mysql on Mac OS X 10.4 Tiger

December 6th, 2006

You probably know that the built-in mysql code in Rails sucks. To rephrase that, the ruby-mysql gem contains better code, so you want that. Rails automatically detects if you have ruby-mysql installed or not, and uses it if you have it.

Most notably, you want to install this gem if you get dropped MySQL connections running your Rails application.

So we do:

689113254a2e12fcbd837def174e522d010

Normall this would install fine, but not on Mac OS X. This is because Mac OS X keeps its code, headers and libraries in odd places (compared to Linux). But don’t panic. There’s an easy solution to all this!

Installing Rails on Ubuntu Dapper / Edgy

December 3rd, 2006

Update 2009-02-19: Bumped to RubyGems version 1.3.1 and MySQL 5 libraries. This guide now works for all recent version of Ubuntu and Debian. Enjoy!

Installing Ruby on Rails on your Ubuntu box is not always as easy as it seems. Here’s a comprehensive overview of the steps you need to take. Mostly you’ll be using apt-get and gems, so it’s not all that hard after all.

This method was tested on both Dapper and Edgy systems. It may work on other Ubuntu releases as well. It’s also possible that it works on Debian.

Besides Rails, I’ll also be install mysql and sqlite3 support.

How to setup a Ubuntu development server – Part 2

December 2nd, 2006

Also read Part 1 – Subversion.

In this part I will tell you how to install Trac on top of your Subversion repositories on your Ubuntu development server. Trac offers you a wiki, roadmap, tickets (tracking system) and access to your SubVersion repository. All of this is bundeled in a very sexy web interface.

Well, let’s get to work now and get Trac installed. When you’re done you will have trac available for all your Subversion repositories.

How to setup a Ubuntu development server – Part 1

December 1st, 2006

Since I’m starting some real work on my final school project, I want to install a Ubuntu development server here at home. I have a Pentium 4 box here that will perform that task.

In this first part I will show you how to install Subversion over WebDAV. All of this will be done in such a way that it’s easy to serve multiple projects at once.

In future parts I will tell you more about installing Trac, FastCGI (with Apache) to host Rails applications and how to use Capistrano to deploy your app properly.

For now, let’s get cracking at Subversion.