Wednesday, January 30, 2008

Nothing new... so just wanted to thank

This guy, who started my morning off with a very simple solution:

Thank you Rspec and thank you

Tuesday, January 22, 2008

Rails Routes Hell

I have spent the last day in the seventh level of Rails hell (or something like that... it's been a while since I've read my Dante). Quite simply, I have been trying to have routes send a url in the form /cgi-bin/query?command=5 to a different controller/action based on the command parameter.

To be honest, I'd prefer to just remove the asinine code in the first place, but given that I don't have time to rewrite a fairly large client, it would be a great deal easier if I could just do a simple url rewrite.

Well, since I did work a solution out, I'll post it here, but good God (what's with my theological allusions today?) - if you have a better way, please tell me.

module ActionController
module Routing

class Route


def recognition_conditions
result = ["(match = #{}.match(path))"]
conditions.each do method, value
result << method =""> request.method,
:command => request.query_parameters['command']

and then in my controller:
map.connect 'cgi/query', :action => 'homepage', :controller => 'home', :conditions => { :command => /1/ }

This works, but isn't there are a good way of doing this without have to extend Rails internals? It just seems like there should be an easier way. I read Jamis articles, and while I learnt a great deal about the routes system, I still didn't get how to do any better that this.

and his routing trick plugin...