0

before destroy コールバックを指定するモデルがあります。何かのようなもの:

Class User < ActiveRecord::Base
  before_destroy :do_destroy
  acts_as_destroyable

  private
  def do_destroy
    puts "A"
  end
end

module ActsAsDestroyable
  def self.included(base)
    base.send(:extend, ActsMethods)
  end

  module ActsMethods
    def acts_as_destroyable(options = {})
      self.send(:include, InstanceMethods)
    end

    module InstanceMethods
      def do_something
        puts "A0"
      end

      def self.included(base)
        base.before_destroy :do_something
      end
    end
  end
end

Destroyable モジュールはユーザーの関連付けと連携するため、「do_destroy」コールバックの前に「do_domething」メソッドを実行する必要があります。どうすればコールバックキューに移動できますか?

4

0 に答える 0