From 6244124833d7d5e2a39f7bba599105b173e13057 Mon Sep 17 00:00:00 2001 From: Libor Pichler Date: Fri, 4 Oct 2019 15:33:43 +0200 Subject: [PATCH] Consolidate has_many --- app/models/vm_or_template.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/models/vm_or_template.rb b/app/models/vm_or_template.rb index 37f691068b6..5747f06ff1a 100644 --- a/app/models/vm_or_template.rb +++ b/app/models/vm_or_template.rb @@ -68,11 +68,10 @@ class VmOrTemplate < ApplicationRecord belongs_to :flavor belongs_to :storage - has_and_belongs_to_many :storages, :join_table => 'storages_vms_and_templates' - belongs_to :storage_profile belongs_to :ext_management_system, :foreign_key => "ems_id" belongs_to :resource_group + belongs_to :tenant # Accounts - Users and Groups has_many :accounts, :dependent => :destroy @@ -125,12 +124,12 @@ class VmOrTemplate < ApplicationRecord has_many :service_resources, :as => :resource has_many :direct_services, :through => :service_resources, :source => :service - belongs_to :tenant has_many :connected_shares, -> { where(:resource_type => "VmOrTemplate") }, :foreign_key => :resource_id, :class_name => "Share" has_many :labels, -> { where(:section => "labels") }, :class_name => "CustomAttribute", :as => :resource, :dependent => :destroy has_many :ems_custom_attributes, -> { where(:source => 'VC') }, :as => :resource, :dependent => :destroy, :class_name => "CustomAttribute" has_many :counterparts, :as => :counterpart, :class_name => "ConfiguredSystem", :dependent => :nullify + has_and_belongs_to_many :storages, :join_table => 'storages_vms_and_templates' acts_as_miq_taggable