我有一个嵌套的表单模型
<%= simple_form_for(@product, :html => { :multipart => true }) do |f| %>
<%= f.input :name %>
#... and some other
<%= f.simple_fields_for :productgroups do |builder| %>
<%= render 'form_productgroup', { :f => builder } %>
<% end %>
<% end %>
## partial-level-1: form_productgroup
<%= f.input :extrapercentage %>
#... and some other
<%= f.simple_fields_for :productmaterials do |builder| %>
<%= render 'form_productmaterial', { :f => builder } %>
<% end %>
## partial-level-2: form_productmaterial
<%= f.input :price %>
#... and some other
=&GT;一切都很好serveride,但我需要通过ajax添加记录,因为每个产品组或productmaterial属于特定类型
现在的问题是:
如何创建一个返回新材料表单的控制器操作?
此代码返回f不存在的错误:
def new_productgroup
@product = Product.find(params[:id])
@productgroup = Productgroup.new(:product_id => @product.id, :materialgroup_id => params[:materialgroup_id])
render "form_productgroup", { :f => ???? }
end
请帮助我!