vendredi 18 mars 2016

When to execute Rails after commit

If I have a concern like this:

module SomeModule
  extend ActiveSupport::Concern

  included do
    after_commit :execute, on: WHEN_TO_EXECUTE
  end
end

Is it possible to specify a constant on the included classes WHEN_TO_EXECUTE in which it holds a symbol of whatever :update, :create?

I it is not possible to make the after_commit dynamic like this with any other way?

Aucun commentaire:

Enregistrer un commentaire