Skip to content

Instantly share code, notes, and snippets.

@indirect
Created June 12, 2012 00:09
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save indirect/2913560 to your computer and use it in GitHub Desktop.
Save indirect/2913560 to your computer and use it in GitHub Desktop.
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'
end
+ 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 = Module.new
+ 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
else
gem 'rails'
end
+ 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