From ee5fa62b37cf92acf8cd3ca47f7861483f9f8d4d Mon Sep 17 00:00:00 2001 From: d-m-u Date: Mon, 22 Jul 2019 17:23:10 -0400 Subject: [PATCH] Cleanup seed_from_array product feature things --- app/models/miq_user_role.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/miq_user_role.rb b/app/models/miq_user_role.rb index 6dab68d08e2..a18915a0978 100644 --- a/app/models/miq_user_role.rb +++ b/app/models/miq_user_role.rb @@ -86,14 +86,14 @@ def self.seed end def self.seed_from_array(roles, array, merge_features = false) + features = MiqProductFeature.all array.each do |hash| feature_ids = hash.delete(:miq_product_feature_identifiers) - - hash[:miq_product_features] = MiqProductFeature.where(:identifier => feature_ids).to_a + hash[:miq_product_features] = features.select { |f| feature_ids.include?(f.identifier) } role = roles[hash[:name]] ||= new(hash.except(:id)) new_role = role.new_record? hash[:miq_product_features] &&= role.miq_product_features if !new_role && merge_features - unless role.settings.nil? # Makse sure existing settings are merged in with the new ones. + unless role.settings.nil? # Make sure existing settings are merged in with the new ones. new_settings = hash.delete(:settings) || {} role.settings.merge!(new_settings) end