activerecord - Rails 3 before_destroy triggered twice -


in rails 3 application there 2 models assinged each other belongs_to , has_one. on both sides there :depended => :destroy configured association. had add :before_destroy callback in 1 of these models. problem callback triggered twice when entity includes callback destroyed. when remove :depended => :destroy in other model, it's triggered once. seems causing problem.

is there elegant way fix ?

:dependent controls happens associated objects when owner destroyed

dependent destroy must alone in model

has_many :comments, dependent: :destroy has_one :position, dependent: :destroy 

sorry english xd


Comments