我有同样的问题
one
one
但那个解决方案对我没有帮助.
这是我强大的参数:
def request_params params.require(:request).permit(:name,:address,:phone,:mobile,:type,:filled_cartridges_attributes => [:cartridge_name,:client_id,:count,:_destroy,:id],
所以我有:_destroy和:id.之前的家伙忘记添加:id to strong params.添加id解决了他的问题.
这是我的请求模型:
has_many :filled_cartridges,inverse_of: :request,dependent: :destroy accepts_nested_attributes_for :filled_cartridges,:reject_if => :all_blank,allow_destroy: true
这就是提交后params的样子:
request: ...some params.... filled_cartridges_attributes: !ruby/hash:ActionController::Parameters '0': !ruby/hash:ActionController::Parameters cartridge_name: HP LaserJet3000 _destroy: 'false' id: '1' '2': !ruby/hash:ActionController::Parameters cartridge_name: new 9 _destroy: '1' id: '13'
这里应该销毁第二个.
但事实并非如此.