after_rollbackトランザクション中に保存または破棄されたオブジェクトに対してのみ呼び出されます。after_rollbackメインクラスまたはクラスにコールバックを設定していますErrorLogか?
実際、クラスでafter_rollbackコールバックを使用するErrorLogのが最も簡単なアプローチのようです。インスタンスを失う唯一のケースはErrorLog、トランザクションがロールバックされた場合です。そのため、次のようなものが機能するはずです。
class MyClass < ActiveRecord::Base
before_save :check_external
def check_external
unless external_says_i_am_okay?
ErrorLog.create!(:message => 'oops')
end
end
end
class ErrorLog < ActiveRecord::Base
after_rollback :save_anyway
def save_anyway
self.save!
end
end
Of course having said all that you might want to consider the performance of getting an external service to validate your models. It might not be sufficiently quick if you're creating objects in the scope of a web request for example. You'd also want to make sure that the ErrorLog#save wouldn't fail as you're going to be outside the scope of a transaction by that point.