Running patched rails, monkey-patch


Does anyone have any tips for running a patched version of rails? I am
currently running rails 1.2.2 and would like to keep up to date with any
future releases. I also want to run with the following patch:

I am unsure how to manage this. Is this something SVN or rake can

If the patch is not too complex you can also apply it as a monkey-
patch. This is quite simple, just create a ruby-file inside lib with
a class in there of the same name, and inside the same modules as
the rails-class. Then add changed versions of all the functions you
want changed.

Require this file at the end of your environment.rb, and you're done.

I myself make use of this method quite extensively, but of course you
shouldn't over-do it and of course try to get improvements and fixes
that everyone would enjoy into the rails-trunk.


Along the same lines, I recently did something similar. This might
not be the best solution, however I created a patches.rb file that
gets loaded by environment, an example in there:

# Monkey Patches
# Fixes a bug in rails 1.2.2 where Arrays are being improperly handled
in query parameters
# It should only be converted to a '/' joined string if it's a :path
if'rails').version.to_s == '1.2.2'
  class ActionController::Routing::RouteSet
    def options_as_params(options)
      options_as_params = options[:controller] ? { :action => "index" } :
      options.each do |k, value|
        options_as_params[k] = (value.class == Array && k.to_s !=
'path') ? value : value.to_param

This way I won't override anything if they fix it in the next release,
and if it still isn't fixed, I can just update the version check.

Anyways, hope that helps some.
  .adam sanderson