store multiple submitter results
This commit is contained in:
@@ -4,24 +4,14 @@
|
||||
#
|
||||
# Table name: submissions
|
||||
#
|
||||
# id :bigint not null, primary key
|
||||
# completed_at :datetime
|
||||
# deleted_at :datetime
|
||||
# email :string not null
|
||||
# ip :string
|
||||
# opened_at :datetime
|
||||
# sent_at :datetime
|
||||
# slug :string not null
|
||||
# ua :string
|
||||
# values :string not null
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# template_id :bigint not null
|
||||
# id :bigint not null, primary key
|
||||
# deleted_at :datetime
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# template_id :bigint not null
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
# index_submissions_on_email (email)
|
||||
# index_submissions_on_slug (slug) UNIQUE
|
||||
# index_submissions_on_template_id (template_id)
|
||||
#
|
||||
# Foreign Keys
|
||||
@@ -31,27 +21,7 @@
|
||||
class Submission < ApplicationRecord
|
||||
belongs_to :template
|
||||
|
||||
attribute :values, :string, default: -> { {} }
|
||||
attribute :slug, :string, default: -> { SecureRandom.base58(8) }
|
||||
|
||||
serialize :values, JSON
|
||||
|
||||
has_one_attached :archive
|
||||
has_many_attached :documents
|
||||
|
||||
has_many_attached :attachments
|
||||
has_many :submitters, dependent: :destroy
|
||||
|
||||
scope :active, -> { where(deleted_at: nil) }
|
||||
|
||||
def status
|
||||
if completed_at?
|
||||
'completed'
|
||||
elsif opened_at?
|
||||
'opened'
|
||||
elsif sent_at?
|
||||
'sent'
|
||||
else
|
||||
'awaiting'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# == Schema Information
|
||||
#
|
||||
# Table name: submitters
|
||||
#
|
||||
# id :bigint not null, primary key
|
||||
# completed_at :datetime
|
||||
# email :string not null
|
||||
# ip :string
|
||||
# opened_at :datetime
|
||||
# sent_at :datetime
|
||||
# slug :string not null
|
||||
# ua :string
|
||||
# uuid :string not null
|
||||
# values :string not null
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# submission_id :bigint not null
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
# index_submitters_on_email (email)
|
||||
# index_submitters_on_slug (slug) UNIQUE
|
||||
# index_submitters_on_submission_id (submission_id)
|
||||
#
|
||||
# Foreign Keys
|
||||
#
|
||||
# fk_rails_... (submission_id => submissions.id)
|
||||
#
|
||||
class Submitter < ApplicationRecord
|
||||
belongs_to :submission
|
||||
|
||||
attribute :values, :string, default: -> { {} }
|
||||
attribute :slug, :string, default: -> { SecureRandom.base58(8) }
|
||||
|
||||
serialize :values, JSON
|
||||
|
||||
has_one_attached :archive
|
||||
has_many_attached :documents
|
||||
|
||||
has_many_attached :attachments
|
||||
|
||||
def status
|
||||
if completed_at?
|
||||
'completed'
|
||||
elsif opened_at?
|
||||
'opened'
|
||||
elsif sent_at?
|
||||
'sent'
|
||||
else
|
||||
'awaiting'
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user