Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
monkeypatch Rails 2.3.14 for Ruby 1.9.3
diff --git a/config/boot.rb b/config/boot.rb
index 69b1a51..2c979cf 100644
--- a/config/boot.rb
+++ b/config/boot.rb
@@ -61,12 +61,30 @@ module Rails
require 'initializer'
+ def monkeypatch_helpers
+ require "active_support"
+ require 'action_controller/helpers'
+ ActionController::Helpers::ClassMethods.send(:define_method, :inherited_with_helper) do |child|
+ inherited_without_helper(child)
+ begin
+ child.master_helper_module =
+ child.master_helper_module.__send__ :include, master_helper_module
+ child.__send__ :default_helper_module!
+ rescue MissingSourceFile => e
+ raise unless e.is_missing?("helpers/#{child.controller_path}_helper")
+ rescue LoadError
+ end
+ end
+ end
def load_rails_gem
if version = self.class.gem_version
gem 'rails', version
gem 'rails'
+ monkeypatch_helpers
rescue Gem::LoadError => load_error
$stderr.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.)
exit 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.