为什么这个:
# edit.html.erb
<%= form_for @product do |f| %>
<%= f.fields_for :shop do |sf| %>
# Nothing here
<% end %>
<% end %>
生成一个隐藏的输入字段:
<input type="hidden" value="23" name="product[shop_attributes][id]" id="product_shop_attributes_id">
?
相关控制器代码:
def edit
@product = Product.find(params[:id])
end