From 541b850015775ed34554b703a93ed56ed0126920 Mon Sep 17 00:00:00 2001 From: baarkerlounger Date: Tue, 12 Oct 2021 09:57:37 +0100 Subject: [PATCH] Linting --- app/controllers/case_logs_controller.rb | 2 +- app/models/case_log.rb | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/controllers/case_logs_controller.rb b/app/controllers/case_logs_controller.rb index 050542551..f039e2d56 100644 --- a/app/controllers/case_logs_controller.rb +++ b/app/controllers/case_logs_controller.rb @@ -45,7 +45,7 @@ class CaseLogsController < ApplicationController form = Form.new(2021, 2022) form.all_pages.map do |page_key, page_info| - define_method(page_key) do |errors = {}| + define_method(page_key) do |_errors = {}| @case_log = CaseLog.find(params[:case_log_id]) render "form/page", locals: { form: form, page_key: page_key, page_info: page_info } end diff --git a/app/models/case_log.rb b/app/models/case_log.rb index bb8dbe54c..aa17eddf6 100644 --- a/app/models/case_log.rb +++ b/app/models/case_log.rb @@ -1,7 +1,6 @@ class CaseLogValidator < ActiveModel::Validator - # Methods need to be named 'validate_' followed by field name - # this is how the metaprogramming of the method name being + # this is how the metaprogramming of the method name being # call in the validate method works. def validate_tenant_code(record) @@ -13,7 +12,7 @@ class CaseLogValidator < ActiveModel::Validator def validate_tenant_age(record) if record.tenant_age.blank? record.errors.add :tenant_age, "Tenant age can't be blank" - elsif !(record.tenant_age.to_s =~ /^[1-9][0-9]?$|^100$/) + elsif !/^[1-9][0-9]?$|^100$/.match?(record.tenant_age.to_s) record.errors.add :tenant_age, "Tenant age must be between 0 and 100" end end @@ -26,9 +25,10 @@ class CaseLogValidator < ActiveModel::Validator end end -class CaseLog < ApplicationRecord +class CaseLog < ApplicationRecord validate :instance_validations attr_writer :previous_page + enum status: { "in progress" => 0, "submitted" => 1 } def instance_validations