diff --git a/app/controllers/locations_controller.rb b/app/controllers/locations_controller.rb index 127c0ec61..be9ee7b41 100644 --- a/app/controllers/locations_controller.rb +++ b/app/controllers/locations_controller.rb @@ -121,11 +121,9 @@ class LocationsController < ApplicationController day = location_params["startdate(3i)"] month = location_params["startdate(2i)"] year = location_params["startdate(1i)"] - if [day, month, year].none?(&:blank?) && Date.valid_date?(year.to_i, month.to_i, day.to_i) - @location.startdate = Time.zone.local(year.to_i, month.to_i, day.to_i) - else - @location.startdate = nil - end + @location.startdate = if [day, month, year].none?(&:blank?) && Date.valid_date?(year.to_i, month.to_i, day.to_i) + Time.zone.local(year.to_i, month.to_i, day.to_i) + end if @location.save(context: :startdate) redirect_to scheme_location_check_answers_path(@scheme, @location, route: params[:route]) else