グループに複数の機能があるモデルがあります
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
そのプラグインの問題 (および他の同様の状況で発生する問題) は、グループ機能を更新するときに、プラグインを 2 回挿入しようとすることです。
属性の更新が 2 回発生する理由がわかりません。act_as_audited (または他のプラグイン) を使用しない場合は問題ありません。しかし、何かを追加するとすぐに、重複エラーが発生します。
早期挿入が発生する必要があると思いますが、干渉するプラグインがある場合にのみ、何度もトリガーされる理由 (およびそれを防止する方法) を見つけることができません。
誰もそのような問題に遭遇しましたか? (または、ネストされた属性を使用してacts_as_auditedを正常に実装しましたか?)
あなたの助けと洞察に感謝します