Ruby on rails rails使用嵌套表单重复插入
我有一个模型,其中一个组具有多个功能Ruby on rails rails使用嵌套表单重复插入,ruby-on-rails,ruby-on-rails-3,nested-forms,nested-attributes,acts-as-audited,Ruby On Rails,Ruby On Rails 3,Nested Forms,Nested Attributes,Acts As Audited,我有一个模型,其中一个组具有多个功能 class Group < ActiveRecord::Base attr_accessible :capabilities_attributes acts_as_audited #<------------------------------- source of error has_associated_audits has_many :capabilities, :dependent => :destroy end
class Group < ActiveRecord::Base
attr_accessible :capabilities_attributes
acts_as_audited #<------------------------------- source of error
has_associated_audits
has_many :capabilities, :dependent => :destroy
end
class Capability < ActiveRecord::Base
acts_as_audited :associated_with => :entity_group
end
类组:实体组关联
结束
还有一个控制器
class GroupsController < ApplicationController
load_and_authorize_resource #cancan authorization
#...
def update
if @group.update_attributes(params[:group])
flash[:notice] = "Group '#{@group}' has been updated."
redirect_to groups_path
else
flash[:alert] = "Group '#{@group}' was not updated."
render :action => "edit"
end
end
end
类组控制器“编辑”
结束
结束
结束
该插件的问题在于(在其他类似情况下也是如此)在更新组功能时,它会尝试插入两次
我不知道为什么属性更新会发生两次。当我不使用acts_as_audited(或其他插件)时,这很好。但一旦我添加了一些内容,就会出现复制错误
我假设有一些早期插入必须发生,但我找不到任何原因,为什么它会被触发(以及如何防止它)太多次,而且只有在有智能插件的时候
有没有人遇到过这样的问题?(或使用嵌套属性成功实现的acts_作为_审核?)
非常感谢您的帮助和见解