diff --git a/app/services/submit_form.rb b/app/services/submit_form.rb index 84f9a20e..939f2756 100644 --- a/app/services/submit_form.rb +++ b/app/services/submit_form.rb @@ -36,15 +36,15 @@ def submit_form! def create_application_records ActiveRecord::Base.transaction do - school = create_school - applicant = create_applicant(school) - @application = create_application(applicant) + create_school + create_applicant + create_application delete_form end end def create_school - School.create!( + @school = School.create!( name: form.school_name, headteacher_name: form.school_headteacher_name, address_attributes: { @@ -56,8 +56,8 @@ def create_school ) end - def create_applicant(school) - Applicant.create!( + def create_applicant + @applicant = Applicant.create!( ip_address: ip_address, given_name: form.given_name, middle_name: form.middle_name, @@ -75,13 +75,13 @@ def create_applicant(school) city: form.city, postcode: form.postcode, }, - school: school, + school: @school, ) end - def create_application(applicant) - Application.create!( - applicant: applicant, + def create_application + @application = Application.create!( + applicant: @applicant, application_date: Date.current.to_s, application_route: form.application_route, application_progress: ApplicationProgress.new, @@ -100,7 +100,7 @@ def delete_form def send_applicant_email GovukNotifyMailer .with( - email: application.applicant.email_address, + email: @applicant.email_address, urn: application.urn, ) .application_submission