Note to self
Checking rails routes
I just had to debug a strange problem with the Routing in JRuby. So in case you need to test the routing mechanism “by hand” go
> jruby script/console
>> ActionController::Routing::Routes.recognize_path('/my/path', {:method => :get})
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/
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' end
Which defines this in a much nicer fashion than matching the route “manually”.
Rails rendering sequence
Rails does a lot of “automagic” stuff, and there seems to be a lack of documentation on how the piping behind that works. For example, there’s the strange fact that you can set up variables in a template that can then be used in it’s layout… so investigated the rendering sequence a bit.
Debugger messes up rdoc
Sometimes it seems that ruby still has a way to go in terms of maturity. Today I got a strange error message when trying to build the rdoc files:
uninitialized constant RubyToken::AlreadyDefinedToken (NameError)
Any idea what it means? It turns out that I forgot to remove a require 'ruby-debug' somewhere in the code, which in turn includes some files from irb, which in turn is incompatible with rdoc. Duh…
Netbeans 6.0, Leopard and “fast debug”
For the new year, I upgraded to a new machine which includes MacOS Leopard. The system looks o.k., a few nice features and not much changed really. However, there are also some annoyances:
