new form if fields changed

pull/718/head
Pete Matsyburka 4 weeks ago
parent 616f7b4fd8
commit 1f149ac67a

@ -10,6 +10,9 @@ class StartFormSelfController < ApplicationController
@submitter = Submitters::StartForm.build_submitters_scope(@template, exclude_completed: true, source: :self) @submitter = Submitters::StartForm.build_submitters_scope(@template, exclude_completed: true, source: :self)
.find_or_initialize_by(email: current_user.email) .find_or_initialize_by(email: current_user.email)
@submitter = Submitter.new(email: current_user.email) if @submitter.persisted? &&
outdated_template_fields?(@submitter, @template)
if (is_new_record = @submitter.new_record?) if (is_new_record = @submitter.new_record?)
@submitter.name = current_user.full_name @submitter.name = current_user.full_name
@ -33,6 +36,12 @@ class StartFormSelfController < ApplicationController
private private
def outdated_template_fields?(submitter, template)
template_fields = submitter.submission.template_fields
template_fields.present? && template_fields != template.fields
end
def authorize_start! def authorize_start!
authorize!(:read, @template) authorize!(:read, @template)

Loading…
Cancel
Save