Add sequential_id to calculate auto incrementing submission id
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user