Rails AJAX: My partial needs a FormBuilder instance
Use fields_for
inside your partial. It performs a similar task but without wrapping the form tags. See the API docs.
how about this?
@template.with_output_buffer do @template.form_for @model_object do |f| f.fields_for :some_nested_attributes do |ff| render :partial => 'nested_attributes', :object => @model_object, :locals => {:form => ff} end end end
this would be especially useful is you need to use the nested fields_for in the partial
You could instantiate a new instance of your form builder in the controller, though it feels sort of lousy to me:
# in the controllerrender :partial => { :f => MyFormBuilder.new(:staff_member, @staff_member, template), :skill_groups => @skill_groups, :staff_member => @staff_member}
Alternatively, you could move more of the update logic to be client side which wouldn't require you to worry about rendering anything at all. You could just update the values via JS. Not sure if that works for your project though.