Files
docuseal/app/models/dynamic_document.rb
T

39 lines
868 B
Ruby
Raw Normal View History

2026-02-12 09:22:08 +02:00
# frozen_string_literal: true
# == Schema Information
#
# Table name: dynamic_documents
#
# id :bigint not null, primary key
# body :text not null
# head :text
2026-04-01 19:07:57 +03:00
# sha1 :string not null
# uuid :string not null
2026-02-12 09:22:08 +02:00
# created_at :datetime not null
# updated_at :datetime not null
# template_id :bigint not null
#
# Indexes
#
# index_dynamic_documents_on_template_id (template_id)
#
# Foreign Keys
#
# fk_rails_... (template_id => templates.id)
#
class DynamicDocument < ApplicationRecord
belongs_to :template
has_many_attached :attachments
has_many :versions, class_name: 'DynamicDocumentVersion', dependent: :destroy
2026-03-05 10:08:29 +02:00
attribute :fields, :json
2026-02-12 09:22:08 +02:00
before_validation :set_sha1
def set_sha1
self.sha1 = Digest::SHA1.hexdigest(body)
end
end