Add sequential_id to calculate auto incrementing submission id

This commit is contained in:
2020-04-12 23:18:55 +02:00
parent 38166282a7
commit bffed7a606
5 changed files with 18 additions and 1 deletions

View File

@@ -2,6 +2,8 @@ class Submission < ApplicationRecord
belongs_to :form
has_many_attached :files
acts_as_sequenced scope: :form_id
validates_presence_of :data, if: :appended_at?
def process_data(submitted_data)
@@ -21,6 +23,10 @@ class Submission < ApplicationRecord
JSON.dump(value)
when 'tinyforms_now'
Time.now.utc.to_formatted_s(:rfc822)
when 'tinyforms_token'
form.token
when 'tinyforms_id'
sequential_id
when ActionDispatch::Http::UploadedFile
# manually create the ActiveStorage attachment because we need the ID of the Attachment to create the URL
# first the file needs to be uplaoded then we can create an Attachment