Archive for June, 2008
Updating Ruby on Ubuntu 8.04
Jun 27th
Pheww.. all test pass after the latest ruby package updates from the ubuntu team.
I was a little worried reading the comments from the official Rails site. From the comments, a lot of people are experiencing problems after using the patch provided by the official Ruby team.
However, today I received an update notification on my Hardy that a package is available with the latest Ruby security updates. So I installed it and no problems accounted so far while testing my Rails2.1 app. Fortunately that the project I’m working on has a good test coverage. (I made sure of it too!)
Firebug < Firefox3 < Hardy Heron
Jun 24th
Last weekend, I finally decided to upgrade my Gutsy to Hardy. After the installation, everything was working fine. The only thing is that I have no Firebug on Firefox3. I tried to install it through it’s website but it said that it’s not compatible with mine.
Googling the net, I found out that it’s a package in the ubuntu repositories. So with a simple
sudo apt-get install firebug
I was
I have only one burning desire
Let me stand next to your fire — Jimi Hendrix
Note: Restart your firefox after installing firebug.
Nested Layouts in Rails
Jun 20th

I was wondering how to keep the layouts in my rails application code DRY – I was close to the point of kicking myself for having to make changes to all my layouts whenever something standard changed – so i researched online and found the above diagram by Matt McCray in his blog.
I used Matt’s method for nesting layouts, but instead of defining a method called sub_layout in my controllers, I called a pre-defined rails controller method:
< % render :partial => “layouts/#{controller.controller_name}” %>
and defined a partial layout named after every controller I had, which had different settings for their own views. Rails has a local variable called ‘controller’ you can use to access its controller’s name and even the action used for the current view. So using this, I don’t have to define additional methods in my controllers, nor use any plugins.
kudos to Matt for coming up with this in the first place. Thanks!
Pair programming explained!
Jun 20th
Here’s the slides I used to explain pair progamming to my peeps – whew!
Pair programming looks like fun. We’ll be doing it next week, so more on this later!!
Before I forget (and I do it a lot), here’s the link to the file
Pair Programming – I Drive, You Show the Way
Jun 16th
Ever gone on a road trip – alone? Not much fun is it? With a Big Mac in your mouth, you’ve got to have one eye on the road, one hand on the steering wheel, the other eye on a map, and the other hand clutching it. Now that’s a feat even unicycle riding, ball juggling circus clowns find hard to do.
It’s the same thing with programming – on the one hand you’ve got to make sure you’re codes are syntactically correct (never mind politically), and on the other, you’ve got to think about software and database design, security, speed, scalability and a whole bunch of other issues. Now i know most of you out there can do this better than a circus clown, but the fact remains – wouldn’t it be better if there where a ‘co-driver’ so to speak?
Here’s where pair programming really shines. I used to think pair programming was just a bunch of ‘poppycock’ – two people sitting working on a single computer one the same set of codes – whatever for? So they both can slap the sense out of each other if one decides to snooze?
It turns out that, when explained the ‘co-driver’ way, it makes a lot of sense. When I do programming, and I reach a design decision point, I tend to stare off into space for a good few minutes while the cogs in my brain turn (rather slowly, I might add). It’s kinda like stopping at the side of the road to refer to your map to decide which way to go (if you’re alone of course). Having someone else figuring out the way, just makes more sense.
Ok, enuff explaining – I’m preparing training slides for this to start pair programming in my team – slides for this next post!
Rails 2.1 Label
Jun 14th
A label method is introduced in Rails 2.1.
The following code:
[sourcecode language="html"]
< % form_for (@post) do |f| %>
< %= f.label :title %>
#Code truncated for clarity
< % end %>
[/sourcecode]
Would generate the following HTML:
[sourcecode language="html"]
[/sourcecode]
If your label contains a css class and if you need another name other than the default column name for your label, just do as following:
[sourcecode language="ruby"]
< %= f.label :title, "Please key in a title", :class => “form_label” %>
[/sourcecode]
The code above will generate the following:
[sourcecode language="html"]
[/sourcecode]
Quote Phobia
Jun 13th
I don’t get it why some people write this
%(Unverified email address. Please check your email for your activation code.)
instead of this
“Unverified email address. Please check your email for your activation code.”
Is it that hard to put those double quote?
Netbeans
Jun 11th
I use Netbeans6.1 when developing in Rails. The thing I like most about it is that I can easily read the docs from a certain method in my code. I just press Ctrl + hover my mouse to that method and walla, the docs appears in my IDE. I can also do that when placing the cursor at that method and pressing Ctrl + \.
It also has code refactoring and code completion. Though I would still be careful on using the refactoring tool. Always check the preview first before you refactor it senseless. Code completion is a bliss but sometimes it can be PITA when you have bubbles coming out on auto mode each time you try to write a code. I have to repeatedly press Escape to make those bubbles disappear.
The most useful shortcut key IMHO is Ctrl + Shift + o. I can easily find the file that I need in my IDE. And the one thing I do frequently is format the code with Ctrl + Shift + F. Although sometimes it messes up my indented hashes.
Even though Netbeans has it own console and has all the right-click goodies when clicking the root project, I am still much more comfortable using my gnome terminal. I open multiple tabs of it when I’m coding. One for the script/server, another for script/console, sometimes for script/dbconsole, and another for those wonderful rake commands.
I also use Aloha for my Netbeans theme. It certainly gives me a textmate like theme. Though if I have the dough, I would buy myself a Macbook Pro and Textmate since all the cool kids uses them.
So yeah, Netbeans is cool and I hope that they can make it load things faster especially on the start-up.
Rails 2.1 script/dbconsole
Jun 9th
It’s been a while since i posted anything up on this blog. Meanwhile, our programmer fadhli, has been busy – in the right way of course.
Here’s a link to his own blog for a post that talks about rails 2.1’s new script that helps manage your database…
And i promised some posts on agile methodology last week… shame on me… one coming up next week!


