Trying to extend ActionView::Helpers::FormBuilder
- by nibbo
Hello
I am trying to DRY up some code by moving some logic into the FormBuilder. After reading the documentation about how to select and alternative form builder the logical solution for me seemed to be something like this.
In the view
<% form_for @event, :builder => TestFormBuilder do |f| %>
<%= f.test %>
<%= f.submit 'Update' %>
<% end %>
and then in app/helpers/application_helper.rb
module ApplicationHelper
class TestFormBuilder < ActionView::Helpers::FormBuilder
def test
puts 'apa'
end
end
end
This, however, gives me an error at the "form_for"
uninitialized constant ActionView::Base::CompiledTemplates::TestFormBuilder
Where am I doing it wrong?