I am trying to build a custom form builder and have looked at the rails guides and other blog posts about doing this. I’ve created an empty builder and reference it from my template expecting no errors since I had not overridden any of the FormBuilder methods, but am getting the following error:
ActionView::Template::Error (uninitialized constant #<Class:0x00007fb774eb16c0>::MyFormBuilder)
Nowhere in the rails guides (api.rubyonrails.org/v18.104.22.168/…/FormBuilder.html ) is it mentioned where to put my custom builder or how to get it recognized. The articles and blog posts that I’ve found either don’t mention it or suggest a number of different ways of going about having it accessible, including putting a require at the top of my template file, which doesn’t sound like best practice.
Any help would be appreciated, and it would be great if the docs were a bit more explicit on how to succeed at having a custom builder loaded.
-----template file--------- <%= fields_for page, builder: MyFormBuilder do |p| %> blah, blah <% end %> ------------ # app/helpers/first_app_builder.rb class MyFormBuilder <ActionView::Helpers::FormBuilder end