Skip to content

Commit

Permalink
group_id now is not nil and we need to exclude it from condition when…
Browse files Browse the repository at this point in the history
… trying to get dashboards for all groups
  • Loading branch information
yrudman committed Nov 11, 2019
1 parent 0f9f1a4 commit 6c8c7ee
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion app/models/miq_widget_set.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,17 @@ 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)
#
# before changes - for default dashboard for froup group_id is nill and userid is nil
if userid.present?
where(:name => name, :group_id => group_id, :userid => userid)
else
where(:name => name, :userid => nil)
end
end

def self.subscribed_for_user(user)
Expand Down

0 comments on commit 6c8c7ee

Please sign in to comment.