Dont copy code

Well it hits me so often… I’m using copy&paste to build similar code. And then it fires me back, when I made some stupid typo. Finding case of such errors is usually very annoying…

I was adding several fields to table in Rails application. I wrote migrations self.up and used this as a skeleton for remove_column in self.down. Of course I have left one coma to much, and struggled over 20 minutes to find what was wrong…

Most annoying Rails/Ruby issue

As for now I have candidate for most annoying issue with Rails. It is related to Ruby itself. But first – have You seen this movie? This screencast compares developing simple webapp in few frameworks – J2EE, Rails, Django, Zope, TurboGears.

Judging from dates showing on screen shots it was made year ago (Feb 2006), and some issues raised against Rails have been resolved long time ago (like using migrations to create databases instead of using SQL directly). But one still is pending. Conflicts in methods names. Using associations is very handy, but often You can have clash with filed in association (thus such auto-generated method) and some Ruby keyword. I have ran on it just with filed in model type which collides with deprecated, but still alive Ruby objects type method. Accessing this field through association results with strange error messages.

So don’t think You will succeed writing @profile.addresses[0].type if You don’t mean calling for class method for @profile.addresses[0].

Is there some viable solution? Maybe something similar to JavaScript’s prototype? Calling @profile.addresses[0].type should return field type from first Address in profile through has_many association, and testing what type of object it is would be @profile.addresses[0].prototype.type?

New plugin required

I was browsing my feeds on Google Reader, and when I was looking at feed from my site (I want to know how it looks in reader), I noticed that Firefox wants to install additional plugin to view my blog entries in Google Reader. Since it is MY feed I was curious, what kind of media was used by me :) which can not be handled by Firefox natively. I clicked on Install missing plugins and saw this (link to bigger version):

Plugin required

Well… :)))