Trying to extend ActionView::Helpers::FormBuilder
Posted
by nibbo
on Stack Overflow
See other posts from Stack Overflow
or by nibbo
Published on 2010-03-19T07:05:34Z
Indexed on
2010/03/19
7:11 UTC
Read the original article
Hit count: 485
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?
© Stack Overflow or respective owner