From da90cd10609f457e9352ff887493e9415a41e8cb Mon Sep 17 00:00:00 2001 From: Tim Felgentreff Date: Fri, 11 Feb 2011 14:55:34 +0100 Subject: [PATCH] hacks for Rails2/3 variance --- init.rb | 4 +++- lib/widget.rb | 14 +++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/init.rb b/init.rb index 835ebc3d4d..2b0f3f160e 100644 --- a/init.rb +++ b/init.rb @@ -4,4 +4,6 @@ fail "upgrade ruby version, ruby < 1.8.7 suffers from Hash#hash bug" if {:a => 1 require 'big_decimal_patch' require 'to_date_patch' -config.middleware.use ::ActionDispatch::Static, "#{root}/assets" +if Rails.version.start_with? "3" + config.middleware.use ::ActionDispatch::Static, "#{root}/assets" +end diff --git a/lib/widget.rb b/lib/widget.rb index 47ff6ac885..9314ee1c08 100644 --- a/lib/widget.rb +++ b/lib/widget.rb @@ -1,14 +1,22 @@ class ActionView::Base def render_widget(widget, subject, options = {}, &block) i = widget.new(subject) - i.config = config - i.controller = controller + if Rails.version.start_with? "3" + i.config = config + i._routes = _routes + else + i.output_buffer = "" + end i._content_for = @_content_for - i._routes = _routes + i.controller = controller i.render_with_options(options, &block).html_safe end end +if Rails.version.start_with? "2" + class ::String; def html_safe; self; end; end +end + class Widget < ActionView::Base include ActionView::Helpers::TagHelper include ActionView::Helpers::AssetTagHelper