【Ruby】Ruby on Rails Part8 at PHP
[2ch|▼Menu]
122:nobodyさん
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)


次ページ
続きを表示
1を表示
最新レス表示
スレッドの検索
類似スレ一覧
話題のニュース
おまかせリスト
▼オプションを表示
暇つぶし2ch

5411日前に更新/279 KB
担当:undef