Sha256: 059f776163530bb22a76d8871a3ffd8acf34ba6e3c3a1d338ed772117aec8aad
Contents?: true
Size: 967 Bytes
Versions: 2
Compression:
Stored size: 967 Bytes
Contents
require 'active_support/concern' module ApplicationRecordConcern extend ActiveSupport::Concern included do after_validation :validation_ko after_commit :message_ok after_rollback :message_ko def validation_ko ActionCable.server.broadcast("messages", { topic: :record, action: detect_action, success: false, valid: false, errors: self.errors.full_messages.uniq, record: self}) if self.errors.any? end def message_ok ActionCable.server.broadcast("messages", { topic: :record, action: detect_action, success: true, valid: true, errors: [], record: self}) end def message_ko ActionCable.server.broadcast("messages", { topic: :record, action: detect_action, success: false, valid: true, errors: [], record: self}) end def detect_action return :create if transaction_include_any_action?([:create]) return :update if transaction_include_any_action?([:update]) :destroy end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
thecore_backend_commons-3.1.3 | config/initializers/concern_application_record.rb |
thecore_backend_commons-3.1.2 | config/initializers/concern_application_record.rb |