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 Shop"}
I get the following error:
Couldn't find Shop with ID=20 for Product with ID=
Question 1
What does this means ?
Question 2
If this is the case, i.e. the id of the shop is known, and the shop with such id already exist, how should I create the @product such that this shop will be assigned to it ?
 
     
    