Why this:
# edit.html.erb
<%= form_for @product do |f| %>
<%= f.fields_for :shop do |sf| %>
# Nothing here
<% end %>
<% end %>
generates a hidden input field:
<input type="hidden" value="23" name="product[shop_attributes][id]" id="product_shop_attributes_id">
?
Relevant controller code:
def edit
@product = Product.find(params[:id])
end
It'll be because the @product you're editing has a shop. Rails has inserted that in the fields_for so that when the form is submitted, it knows which shop those nested attributes are for. It's default nested attributes behaviour.