add account_id to submissions

This commit is contained in:
Pete Matsyburka
2024-02-03 14:39:28 +02:00
parent ddcb5c5d40
commit 8630c68631
9 changed files with 41 additions and 6 deletions
+3 -1
View File
@@ -10,7 +10,8 @@ class StartFormController < ApplicationController
before_action :load_template
def show
@submitter = @template.submissions.new.submitters.new(uuid: @template.submitters.first['uuid'])
@submitter = @template.submissions.new(account_id: @template.account_id)
.submitters.new(uuid: @template.submitters.first['uuid'])
end
def update
@@ -68,6 +69,7 @@ class StartFormController < ApplicationController
end
submitter.submission ||= Submission.new(template:,
account_id: template.account_id,
template_submitters: template.submitters,
source: :link)
+3 -1
View File
@@ -15,11 +15,13 @@
# template_submitters :text
# created_at :datetime not null
# updated_at :datetime not null
# account_id :bigint not null
# created_by_user_id :bigint
# template_id :bigint not null
#
# Indexes
#
# index_submissions_on_account_id (account_id)
# index_submissions_on_created_by_user_id (created_by_user_id)
# index_submissions_on_slug (slug) UNIQUE
# index_submissions_on_template_id (template_id)
@@ -31,7 +33,7 @@
#
class Submission < ApplicationRecord
belongs_to :template
has_one :account, through: :template
belongs_to :account
belongs_to :created_by_user, class_name: 'User', optional: true
has_many :submitters, dependent: :destroy
+1 -1
View File
@@ -36,7 +36,7 @@
class Submitter < ApplicationRecord
belongs_to :submission
has_one :template, through: :submission
has_one :account, through: :template
has_one :account, through: :submission
attribute :values, :string, default: -> { {} }
attribute :preferences, :string, default: -> { {} }