Files
eminuxCRM/app/models/concerns/auditable.rb
T
eminuxandCursor c4e5f289cf
CI / scan_ruby (push) Failing after 11m20s
CI / scan_js (push) Successful in 10m35s
CI / lint (push) Has been cancelled
Commit iniziale di eminuxCRM: CRM Rails con pipeline, campagne email e Docker.
Include autenticazione, progetti isolati, mail marketing HTML con SMTP, test A/B e editor WYSIWYG.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-17 23:01:48 +02:00

22 lines
436 B
Ruby

module Auditable
extend ActiveSupport::Concern
included do
belongs_to :created_by, class_name: "User", optional: true
belongs_to :updated_by, class_name: "User", optional: true
before_create :set_created_by
before_save :set_updated_by
end
private
def set_created_by
self.created_by_id ||= Current.user&.id
end
def set_updated_by
self.updated_by_id = Current.user&.id if Current.user
end
end