From ec8deecf667acefc1a4e5970cfc3915475bf7274 Mon Sep 17 00:00:00 2001 From: Brandon Dunne Date: Wed, 13 Jun 2018 17:21:11 -0400 Subject: [PATCH] Remove hacked resource relation and update column_name --- app/models/miq_schedule.rb | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/app/models/miq_schedule.rb b/app/models/miq_schedule.rb index 3b7e44757e91..522f23cc0e91 100644 --- a/app/models/miq_schedule.rb +++ b/app/models/miq_schedule.rb @@ -1,6 +1,6 @@ class MiqSchedule < ApplicationRecord - include ReservedMixin - reserve_attribute :resource_id, :big_integer + include DeprecationMixin + deprecate_attribute :towhat, :resource_type validates :name, :uniqueness => {:scope => [:userid, :towhat]} validates :name, :description, :towhat, :run_at, :presence => true @@ -14,6 +14,7 @@ class MiqSchedule < ApplicationRecord belongs_to :file_depot belongs_to :miq_search + belongs_to :resource, :polymorphic => true belongs_to :zone scope :in_zone, lambda { |zone_name| @@ -42,11 +43,6 @@ class MiqSchedule < ApplicationRecord default_value_for :enabled, true default_value_for(:zone_id) { MiqServer.my_server.zone_id } - def resource - # HACK: this should be a real relation, but for now it's using a reserve_attribute for backport reasons - Object.const_get(towhat).find_by(:id => resource_id) - end - def set_start_time_and_prod_default run_at # Internally this will correct :start_time to UTC self.prod_default = "system" if SYSTEM_SCHEDULE_CLASSES.include?(towhat.to_s)