09/09/25 20:29:53
困っていることがあります。
論理削除プラグインのacts_as_paranoidと、階層構造を1つのformで保存したりするattribute_fu プラグイン
を導入しているのですが、
モデルHoge
acts_as_paranoid
has_many :foobars, :dependent => :destroy, :attributes => true
モデルFoobar
acts_as_paranoid
belongs_to :hoge
などとというように書いておくと、
Hogeをdestroyで消した時に、:dependent => :destroyにて関連付けたFoobar郡を同時に論理削除してくれるのですが、
中で freezeをかましているようでして、
:attributes => true をつけて attribute_fu の管理下においた状態だと、
Hogeをsave時に freezeされたfoobars を保存しようとして、
can't modify frozen hash
などとエラーがでます orz
こういう状況を回避する方法はないのでしょうか?
destroyのときだけ、:attributes => true をなくす、というか、
attribute_fuで base.class_eval されている中の
after_update :save_managed_associations
のフック処理(この中で該当のエラーが起きている)を回避する方法といいますか…。
acts_as_paranoidは下記のものを、
technoweenie's acts_as_paranoid at master - GitHub
URLリンク(github.com)
attribute_fuは下記のものを利用しています。
giraffesoft's attribute_fu at master - GitHub
URLリンク(github.com)