From 59a217598aa96e36f056ee8ce2f155fccc78d03d Mon Sep 17 00:00:00 2001 From: Teresa Martyny Date: Thu, 14 Apr 2016 20:40:12 -0700 Subject: [PATCH] Problem: When runtime is nil, a no method error is raised for round on nil:NilClass. Solution: Use lonely operator to handle nil value for runtime and display N/A in these cases. --- lib/sidetiq/views/history.erb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/sidetiq/views/history.erb b/lib/sidetiq/views/history.erb index 4e660c1..dae4624 100644 --- a/lib/sidetiq/views/history.erb +++ b/lib/sidetiq/views/history.erb @@ -23,10 +23,11 @@ <% @history.each do |entry| %> <% entry = Sidekiq.load_json(entry).symbolize_keys %> + <% runtime = entry[:runtime]&.round(3) || "N/A" %> <%= entry[:status].capitalize %> <%= Time.parse(entry[:timestamp]).strftime("%m/%d/%Y %I:%M:%S%p") %> - <%= entry[:runtime].round(3) %> s + <%= runtime %> s <% if entry[:status] == 'failure' %>