Be sure where your methods are chained to…

I’ve just figured out a quite obscure bug in our app. It all started like this:

record.freeze.things # record is an ActiveRecord, and "things" is an association on that record.
TypeError: can't modify frozen object
	from (irb):2:in `instance_variable_set'
	from (irb):2

The code above shouldn’t crash, because ActiveRecord hast its own #freeze method, which will still allow access to the associations. But our record behaved as if Object#freeze had been called on it. What happend?

Continue reading “Be sure where your methods are chained to…”


Rails forms and params

Another not to self: Rails has the cool feature that you it will map all the values from your submitted forms into the params hash. And, if you create input fields that are named “something[bla]“, it will automatically create a nested hash so that you will be able to access params[:thingyform][:something].

But what if you just have a list of things that you need to submit? In this case, just name multiple form fields something[], and the params will contain an array.

Assit on GitHub – the gem is back

I while ago I wrote a small ruby library for runtime assertions to use in our projects. While I didn’t use it as heavily as expected, it has been useful in debugging in the beginning. It offers the possibility to include extra runtime checks – even expensive ones – to the code, which can be disabled in production code.

I’ve moved the project to github now, and the gem is not broken anymore. This means that you can

sudo gem install averell23-assit

from The old gem (assit) is still around on rubyforge for some reason, but it’ll remain on 0.0.3 forever. If you use this, better get the github version (averell23-assit) now.

Mingle Project Management

In my quest for the perfect project management tool, I tested out Mingle (if you want to see all those features, just browse their site).

It’s a really flexible tool and with the new version it’s really getting close to what we’d need. They got some fresh ideas, a flexible tool and lots of eye-candy. It was even easy to set up. I’d try it for real, if it weren’t for those few big gripes…

Continue reading “Mingle Project Management”

A little routing trickery

Documentation in Rails seems notoriously bad – the documentation appears to be painfully incomplete. Anyway, all the cool kiddies will tell you how to do resource routing; but I wanted a bit more. In particular, i wanted to have URLs that work like http://xxx/things//. Where is the id of the thing you’re watching, and is an additonal identifier that is passed to the controller. For example, you could have a rout that let’s you do http://xxx/cars/bug/green, to show you the green version of the bug.

After a little trial and error, I found that this will be possible using a route like this:

map.resources :cars do |cars|
  cars.connect ':colour', :controller => 'cars',
    :action => 'car_with_colour'

Which defines this in a much nicer fashion than matching the route “manually”.

The curse of blogs and vidcasts

It drives me crazy: Lot’s of those projects, especially in the Rails world think it’s a cool thing to have a “project” homepage that consists of a blog garnished with some video podcasts. But while this may look flashy, it’s not an excuse for a complete absence of structure and documentation.

I have to admit that what put me over the top today was the ruby-debug “home page”. It’s really a great tool that I use daily, but each time I visit this page I’m on the edge.

First thing, it’s a blog. I hate it. A blog is for news, but when I go to this page I want documentation. Yes, there is this little tutorial. If it’s not accidentally linked from a post on the front page I have to dig through all the “ruby-debug” posts to find it. At least it explains all the commands in the debugger, but it doesn’t go into the API to call the debugger from your code.

In the end, what would be so hard to put your documentation on a static page page that is linked from the front page? And maybe – behold – even add a link to the rdoc documentation that you can automatically generate from you code?

Continue reading “The curse of blogs and vidcasts”

Blog at

Up ↑

%d bloggers like this: