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 13, 2019
1 parent 0f9f1a4 commit 6ca85cb
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions app/models/miq_widget_set.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 6ca85cb

Please sign in to comment.