rails/rails — pull request #17866 by bogdan (2014-12-01 16:42:05+00:00)
Title: Bugfix config.action_view.default_form_builder option

`default_form_builder` option don't currently work on Rails 4.1.1.

I've instigated the issue and found that there is a method name
here: https://github.com/rails/rails/blob/8ed5b46ce65db067eb583e902f851a1f60f5b406/actionview/lib/action_view/helpers/form_helper.rb#L1938

and here: https://github.com/rails/rails/blob/8ed5b46ce65db067eb583e902f851a1f60f5b406/actionview/lib/action_view/helpers/form_helper.rb#L1213

Method from the second link is overwiten by code under first link.

And the trickiest thing is that this is not reproducable in `ActionView` test suite because `FormHelperTest` instance where `form_for` is called in test don't inherit `ActionView::Base`, the instance where `form_for` is called in live application inherit this class.

```
[1141, 1150] in /Users/bogdan/.rvm/gems/ruby-2.1.5@talkable/gems/actionview-4.1.1/lib/action_view/helpers/form_helper.rb
1141: object = record_name
1142: object_name = model_name_from_record_or_class(object).param_key
1143: end
1144:
1145: require 'byebug'; byebug
=> 1146: builder = options[:builder] || default_form_builder
1147: builder.new(object_name, object, self, options)
1148: end
1149:
1150: def default_form_builder
(byebug) is_a?(ActionView::Base)
true
(byebug)
```

`FormHelperTest` can not inherit `ActionView::Base` because of how the test env is designed:
https://github.com/rails/rails/blob/8ed5b46ce65db067eb583e902f851a1f60f5b406/actionview/test/template/form_helper_test.rb#L4

So the test here is writen for `Railtie` that is close to live application.

The best way to fix the issue is avoid unnecessary instance accessor for `default_form_builder` on `ActionView::Base`.