情况:
class Cellar < ActiveRecord::Base
belongs_to :house, dependent: :destroy
accepts_nested_attributes_for :house, allow_destroy: true
attr_accessible :house_id, :house_attributes, [...]
end
.
class House < ActiveRecord::Base
has_one: cellar
end
问题:
当我发送表单并在Cellar
中包含键值对时,House 会被销毁,但不会更新为 NULL。"_destroy" => "true"
house_attributes
Cellar.house_id
这是正常行为吗?我应该如何最好地解决这个问题?