Using Ruby 2.1.1 Rails 4.1.4
Hi,
I've been banging my head on a really strange issue I'm seeing with FormHelper. I'm simply trying to build a form using form_for
and I'm getting the cannot call new for nil class
error when the view tries to render. Through the backtrace, I found that the issue is actually in:
ActionView::Helpers::FormHelper#instantiate_builder:1145-1146
builder = options[:builder] || default_form_builder
builder.new(object_name, object, self, options)
default_form_builder
is defined as follows in ActionView::Helpers::FormHelper
def default_form_builder
builder = ActionView::Base.default_form_builder
builder.respond_to?(:constantize) ? builder.constantize : builder
end
I have not added a Custom Form Builder and am simply trying to use the default. When I check what ActionView::Base.default_form_builder
is, I get nil.
The 2 solutions to get it to work for me were:
- Pass a Form Builder Object to the form_for options[:builder] hash
- Add the following line in my environment config
config.action_view.default_form_builder = ActionView::Helpers::FormBuilder
I'm using 2) for now but both of these shouldn't be necessary.
I've looked everywhere but no luck with what is going on. Thanks for any help!