Skip to content

Commit

Permalink
Consolidate has_many
Browse files Browse the repository at this point in the history
  • Loading branch information
lpichler committed Oct 4, 2019
1 parent 9dc07f0 commit 6244124
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions app/models/vm_or_template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 6244124

Please sign in to comment.