From 880f2ba4f8579e15882d204a4cad48e37d0844e3 Mon Sep 17 00:00:00 2001 From: Nick LaMuro Date: Mon, 18 Jun 2018 20:25:36 -0500 Subject: [PATCH] Add `nil` check for report.extras on save hooks https://bugzilla.redhat.com/show_bug.cgi?id=1590908 --- app/models/miq_report_result.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/miq_report_result.rb b/app/models/miq_report_result.rb index 3e2e98da9d0..b0a0656f8a5 100644 --- a/app/models/miq_report_result.rb +++ b/app/models/miq_report_result.rb @@ -46,8 +46,8 @@ class MiqReportResult < ApplicationRecord # the remainder of the object's instantiation. The `after_commit` hook # specifically is probably overkill, but allows us to not break existing code # that expects the temporary chargeback data in the instantiated object. - before_save { @_extra_groupings = report.extras.delete(:grouping) if report.kind_of?(MiqReport) } - after_commit { report.extras[:grouping] = @_extra_groupings if report.kind_of?(MiqReport) } + before_save { @_extra_groupings = report.extras.delete(:grouping) if report.kind_of?(MiqReport) && report.extras } + after_commit { report.extras[:grouping] = @_extra_groupings if report.kind_of?(MiqReport) && report.extras } delegate :table, :to => :report_results, :allow_nil => true