Skip to content

Commit

Permalink
Configuration values should be on AV::Base.
Browse files Browse the repository at this point in the history
  • Loading branch information
josevalim committed Feb 2, 2010
1 parent ec4b18e commit 95eadb3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 20 deletions.
21 changes: 4 additions & 17 deletions actionpack/lib/action_view/helpers/form_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ def fields_for(record_or_name_or_array, *args, &block)
object_name = ActionController::RecordIdentifier.singular_class_name(object)
end

builder = options[:builder] || ActionView.default_form_builder
builder = options[:builder] || ActionView::Base.default_form_builder
yield builder.new(object_name, object, self, options, block)
end

Expand Down Expand Up @@ -1208,21 +1208,8 @@ def nested_child_index(name)
end
end

class << ActionView
attr_accessor :default_form_builder
class Base
cattr_accessor :default_form_builder
@@default_form_builder = ::ActionView::Helpers::FormBuilder
end

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 changes: 3 additions & 3 deletions actionpack/test/template/form_helper_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1195,8 +1195,8 @@ def test_form_for_with_labelled_builder
end

def test_default_form_builder
old_default_form_builder, ActionView.default_form_builder =
ActionView.default_form_builder, LabelledFormBuilder
old_default_form_builder, ActionView::Base.default_form_builder =
ActionView::Base.default_form_builder, LabelledFormBuilder

form_for(:post, @post) do |f|
concat f.text_field(:title)
Expand All @@ -1213,7 +1213,7 @@ def test_default_form_builder

assert_dom_equal expected, output_buffer
ensure
ActionView.default_form_builder = old_default_form_builder
ActionView::Base.default_form_builder = old_default_form_builder
end

def test_default_form_builder_with_active_record_helpers
Expand Down

0 comments on commit 95eadb3

Please sign in to comment.