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 diff --git a/lib/widget/settings.rb b/lib/widget/settings.rb index ce81e44bce..4a9e15f6a6 100644 --- a/lib/widget/settings.rb +++ b/lib/widget/settings.rb @@ -1,6 +1,6 @@ class Widget::Settings < Widget::Base def render - form_for @query, :url => "#", :html => {:id => 'query_form', :method => :post} do |query_form| + form_tag("#", {:id => 'query_form', :method => :post}) do |query_form| content_tag :div, :id => "query_form_content" do fieldsets = render_widget Widget::Settings::Fieldset, @query, { :type => "filter" } do