From 6ca85cbf4de1de640c4bf91ac4e79b958730eb8d Mon Sep 17 00:00:00 2001 From: Yuri Rudman Date: Mon, 11 Nov 2019 13:57:47 -0500 Subject: [PATCH] group_id now is not nil and we need to exclude it from condition when trying to get dashboards for all groups --- app/models/miq_widget_set.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/models/miq_widget_set.rb b/app/models/miq_widget_set.rb index 32d4c3e6d93..e0dc8cba054 100644 --- a/app/models/miq_widget_set.rb +++ b/app/models/miq_widget_set.rb @@ -28,10 +28,14 @@ def self.destroy_user_versions end def self.where_unique_on(name, user = nil) + # user is nil for dashboards set for group userid = user.try(:userid) - group_id = user.try(:current_group_id) # a unique record is defined by name, group_id and userid - where(:name => name, :group_id => group_id, :userid => userid) + if userid.present? + where(:name => name, :group_id => user.current_group_id, :userid => userid) + else + where(:name => name, :userid => nil) + end end def self.subscribed_for_user(user)