overridey Destroy但保持回调

时间:2016-04-26 09:00:20

标签: ruby-on-rails ruby ruby-on-rails-3

ActiveRecod模型,它覆盖destroy方法,实际上只是“软删除”对象。如果我们覆盖destroy方法,我们会动态创建许多before_filters,但不会调用它们。

before_destroy {
  p "before_destroy"
}

def destroy
  soft_delete
end

1 个答案:

答案 0 :(得分:0)

  def destroy
    _run_destroy_callbacks do
      soft_delete
    end
  end