From 485a977d1a8c6155f72b932a5b54452f8a7f980a Mon Sep 17 00:00:00 2001 From: Rick Barrette Date: Sun, 1 Mar 2026 21:31:28 -0500 Subject: [PATCH] Use Safe Navigation Operator &. --- app/views/customers/_details.html.erb | 4 ++-- app/views/qbo/_settings.html.erb | 4 ++-- lib/redmine_qbo/hooks/users_show_hook_listener.rb | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/views/customers/_details.html.erb b/app/views/customers/_details.html.erb index 33b6b05..940f7f3 100644 --- a/app/views/customers/_details.html.erb +++ b/app/views/customers/_details.html.erb @@ -13,12 +13,12 @@ <%=t(:label_primary_phone)%> - <%= number_to_phone(customer.primary_phone.gsub(/[^\d]/, '').to_i, area_code: true) if customer.primary_phone %> + <%= number_to_phone(customer&.primary_phone&.gsub(/[^\d]/, '').to_i, area_code: true) %> <%=t(:label_mobile_phone)%> - <%= number_to_phone(customer.mobile_phone.gsub(/[^\d]/, '').to_i, area_code: true) if customer.mobile_phone %> + <%= number_to_phone(customer&.mobile_phone&.gsub(/[^\d]/, '').to_i, area_code: true) %> diff --git a/app/views/qbo/_settings.html.erb b/app/views/qbo/_settings.html.erb index f559e54..ad98c83 100644 --- a/app/views/qbo/_settings.html.erb +++ b/app/views/qbo/_settings.html.erb @@ -66,12 +66,12 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI <%=t(:label_oauth_expires)%> - <%= if Qbo.exists? then QboConnectionService.current!.oauth2_access_token_expires_at end %> + <%= QboConnectionService.current!&.oauth2_access_token_expires_at %> <%=t(:label_oauth2_refresh_token_expires_at)%> - <%= if Qbo.exists? then QboConnectionService.current!.oauth2_refresh_token_expires_at end %> + <%= QboConnectionService.current!&.oauth2_refresh_token_expires_at %> diff --git a/lib/redmine_qbo/hooks/users_show_hook_listener.rb b/lib/redmine_qbo/hooks/users_show_hook_listener.rb index 5c6e0a6..d62dc96 100644 --- a/lib/redmine_qbo/hooks/users_show_hook_listener.rb +++ b/lib/redmine_qbo/hooks/users_show_hook_listener.rb @@ -20,7 +20,7 @@ module RedmineQbo #Employee.update_all # Check to see if there is a quickbooks user attached to the issue - @selected = context[:user].employee.id if context[:user].employee + @selected = context[:user]&.employee&.id # Generate the drop down list of quickbooks contacts return "

#{context[:form].select :employee_id, Employee.all.pluck(:name, :id), selected: @selected, include_blank: true}

"