module Erector
  class RailsFormBuilder
    attr_reader :parent, :template

    def initialize(object_name, object, template, options, proc)
      @template = template
      @parent = ActionView::Helpers::FormBuilder.new(object_name, object, template, options, proc)
    end

    def method_missing(method_name, *args, &block)
      if parent.respond_to?(method_name)
        return_value = parent.send(method_name, *args, &block)
        template.concat(return_value) if return_value.is_a?(String)
        return_value
      else
        super
      end
    end
  end
end
module Erector
  class RailsFormBuilder
    attr_reader :parent, :template

    def initialize(object_name, object, template, options, proc)
      @template = template
      @parent = ActionView::Base.default_form_builder.new(object_name, object, template, options, proc)
    end

    def method_missing(method_name, *args, &block)
      if parent.respond_to?(method_name)
        return_value = parent.send(method_name, *args, &block)
        template.concat(return_value) if return_value.is_a?(String)
        return_value
      else
        super
      end
    end
  end
end
Make sure that we use whatever the default form builder for the app, in case it's been overridden by the user in rails environment.rb, instead of just assuming it's always the ActionView form builder
Make sure that we use whatever the default form builder for the app, in case it's been overridden by the user in rails environment.rb, instead of just assuming it's always the ActionView form builder
