From c2e35bc71a76b35885ae72d959ce3cac6002c020 Mon Sep 17 00:00:00 2001 From: natdeanlewissoftwire Date: Mon, 14 Nov 2022 14:33:47 +0000 Subject: [PATCH] fix: remove @locations in location model --- app/models/location.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/models/location.rb b/app/models/location.rb index 51824c2a9..ca0b3fe9f 100644 --- a/app/models/location.rb +++ b/app/models/location.rb @@ -384,7 +384,7 @@ class Location < ApplicationRecord def deactivation_date_errors(params) if params[:location][:deactivation_date].blank? && params[:location][:deactivation_date_type].blank? - @location.errors.add(:deactivation_date_type, message: I18n.t("validations.location.deactivation_date.not_selected")) + .errors.add(:deactivation_date_type, message: I18n.t("validations.location.deactivation_date.not_selected")) end if params[:location][:deactivation_date_type] == "other" @@ -395,11 +395,11 @@ class Location < ApplicationRecord collection_start_date = FormHandler.instance.current_collection_start_date if [day, month, year].any?(&:blank?) - @location.errors.add(:deactivation_date, message: I18n.t("validations.location.deactivation_date.not_entered")) + errors.add(:deactivation_date, message: I18n.t("validations.location.deactivation_date.not_entered")) elsif !Date.valid_date?(year.to_i, month.to_i, day.to_i) - @location.errors.add(:deactivation_date, message: I18n.t("validations.location.deactivation_date.invalid")) + errors.add(:deactivation_date, message: I18n.t("validations.location.deactivation_date.invalid")) elsif !Date.new(year.to_i, month.to_i, day.to_i).between?(collection_start_date, Date.new(2200, 1, 1)) - @location.errors.add(:deactivation_date, message: I18n.t("validations.location.deactivation_date.out_of_range", date: collection_start_date.to_formatted_s(:govuk_date))) + errors.add(:deactivation_date, message: I18n.t("validations.location.deactivation_date.out_of_range", date: collection_start_date.to_formatted_s(:govuk_date))) end end end