Files
old-holivud2/app/models/concerns/approvable.rb

27 lines
627 B
Ruby
Raw Normal View History

2020-07-20 13:28:40 +00:00
module Approvable
extend ActiveSupport::Concern
2020-08-24 15:52:23 +02:00
2020-07-20 13:28:40 +00:00
included do
2020-08-24 15:52:23 +02:00
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
2020-07-20 13:28:40 +00:00
def approve_by(user)
return unless approved_at.nil?
2020-08-24 15:52:23 +02:00
2020-07-20 13:28:40 +00:00
self.approved_by_user_name = user.full_name
self.approved_by_user_email = user.email
2020-08-24 15:52:23 +02:00
self.approved_at = BigMediaTime.time_zone_now
2020-07-20 13:28:40 +00:00
end
2020-08-24 15:52:23 +02:00
2020-07-20 13:28:40 +00:00
def approved?
self.approved_at.present?
end
end
end