Rails 3: How does “accepts_nested_attributes_for” work?
问题 Consider the following association: class Product < ActiveRecord::Base belongs_to :shop accepts_nested_attributes_for :shop end If params[:product][:shop_attributes] = {"name" => "My Shop"} and I do: @product = Product.new(params[:product]) @product.save a new shop with name "My Shop" is created and assigned to the @product , as expected. However, I can't figure out what happens when shop_attributes contains some id , like: params[:product][:shop_attributes] = {"id" => "20", "name" => "My