module Approvable extend ActiveSupport::Concern included do include ActiveStorageSupport::SupportForBase64 has_one_base64_attached :approved_by_user_signature # Requires signature when saving in the approval context with_options on: :approval do validates :approved_by_user_signature, attached: true end def approve_by(user) return unless approved_at.nil? self.approved_by_user_name = user.full_name self.approved_by_user_email = user.email self.approved_at = BigMediaTime.time_zone_now end def approved? self.approved_at.present? end end end