diff --git a/app/models/frame.rb b/app/models/frame.rb index 5d6c6cd07..c19fa50f0 100644 --- a/app/models/frame.rb +++ b/app/models/frame.rb @@ -11,13 +11,12 @@ class Frame < ApplicationRecord # rubocop:disable Metrics/ClassLength belongs_to :bay - has_one :islet, through: :bay - has_one :room, through: :islet - has_many :materials, -> { order("servers.position desc") }, class_name: "Server", dependent: :restrict_with_error has_many :pdus, -> { only_pdus }, class_name: "Server", dependent: :restrict_with_error has_many :servers, -> { no_pdus.order("servers.position desc") }, class_name: "Server", dependent: :restrict_with_error + has_one :islet, through: :bay + has_one :room, through: :islet delegate :name, to: :room, prefix: true, allow_nil: true validates :position, uniqueness: { scope: :bay_id } diff --git a/app/models/permission_scope_domain.rb b/app/models/permission_scope_domain.rb index 2063d9d18..8b01e7518 100644 --- a/app/models/permission_scope_domain.rb +++ b/app/models/permission_scope_domain.rb @@ -3,4 +3,6 @@ class PermissionScopeDomain < ApplicationRecord belongs_to :permission_scope belongs_to :domaine + + delegate :to_s, to: :permission_scope end diff --git a/app/models/server.rb b/app/models/server.rb index fffec8ead..60971d5f6 100644 --- a/app/models/server.rb +++ b/app/models/server.rb @@ -8,11 +8,11 @@ class Server < ApplicationRecord # rubocop:disable Metrics/ClassLength has_changelog belongs_to :frame - belongs_to :modele, counter_cache: true belongs_to :gestion, optional: true, counter_cache: true belongs_to :domaine, optional: true, counter_cache: true belongs_to :cluster, optional: true, counter_cache: true belongs_to :stack, optional: true, counter_cache: true + belongs_to :modele, counter_cache: true has_one :bay, through: :frame has_one :islet, through: :frame @@ -27,6 +27,7 @@ class Server < ApplicationRecord # rubocop:disable Metrics/ClassLength has_many :cables, through: :connections has_many :moves, as: :moveable, dependent: :destroy has_many :documents, dependent: :restrict_with_error + # TODO: should be plural has_many :external_app_record, dependent: :destroy has_one_attached :photo diff --git a/app/views/rooms/destroy.html.erb b/app/views/rooms/destroy.html.erb index 349b907a0..9d119945b 100644 --- a/app/views/rooms/destroy.html.erb +++ b/app/views/rooms/destroy.html.erb @@ -8,8 +8,8 @@