Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Move default_form_builder to ActionView so it'll work in environments…

… not using ActionView::Base
  • Loading branch information...
commit b20d68446d2fe98d129385a17a3a4cdacd4b5025 1 parent 0f2914b
Yehuda Katz wycats authored
18 actionpack/lib/action_view/helpers/form_helper.rb
View
@@ -488,7 +488,7 @@ def fields_for(record_or_name_or_array, *args, &block)
object_name = ActionController::RecordIdentifier.singular_class_name(object)
end
- builder = options[:builder] || ActionView::Base.default_form_builder
+ builder = options[:builder] || ActionView.default_form_builder
yield builder.new(object_name, object, self, options, block)
end
@@ -1054,9 +1054,21 @@ def nested_child_index(name)
end
end
- class << Base
+ class << ActionView
attr_accessor :default_form_builder
end
- Base.default_form_builder = ::ActionView::Helpers::FormBuilder
+ self.default_form_builder = ::ActionView::Helpers::FormBuilder
+
+ # 2.3 compatibility
+ class << Base
+ def default_form_builder=(builder)
+ ActionView.default_form_builder = builder
+ end
+
+ def default_form_builder
+ ActionView.default_form_builder
+ end
+ end
+
end
6 actionpack/test/template/form_helper_test.rb
View
@@ -1024,8 +1024,8 @@ def test_form_for_with_labelled_builder
end
def test_default_form_builder
- old_default_form_builder, ActionView::Base.default_form_builder =
- ActionView::Base.default_form_builder, LabelledFormBuilder
+ old_default_form_builder, ActionView.default_form_builder =
+ ActionView.default_form_builder, LabelledFormBuilder
form_for(:post, @post) do |f|
concat f.text_field(:title)
@@ -1042,7 +1042,7 @@ def test_default_form_builder
assert_dom_equal expected, output_buffer
ensure
- ActionView::Base.default_form_builder = old_default_form_builder
+ ActionView.default_form_builder = old_default_form_builder
end
def test_default_form_builder_with_active_record_helpers
Please sign in to comment.
Something went wrong with that request. Please try again.