Skip to content

Instantly share code, notes, and snippets.

@julianrubisch
Created May 5, 2021 15:05
Show Gist options
  • Save julianrubisch/1bb354960f61beeeababb5cb104900b6 to your computer and use it in GitHub Desktop.
Save julianrubisch/1bb354960f61beeeababb5cb104900b6 to your computer and use it in GitHub Desktop.
# app/models/application_record.rb
class ApplicationRecord < ActiveRecord::Base
self.abstract_class = true
cattr_accessor :skip_callbacks
end
# app/models/concerns/user_notifiable.rb
module UserNotifiable
included do
after_commit :notify_users, unless: :skip_callbacks
end
end
# db/seeds.rb
ApplicationRecord.skip_callbacks = true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment