From 4c3a53f1c5b909bad62520f1e261100cb96ac6ed Mon Sep 17 00:00:00 2001 From: Brandon Dunne Date: Wed, 13 Jun 2018 16:58:30 -0400 Subject: [PATCH] Add resource relation hack --- app/models/miq_schedule.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/models/miq_schedule.rb b/app/models/miq_schedule.rb index ef6798480b3..7d2b1720427 100644 --- a/app/models/miq_schedule.rb +++ b/app/models/miq_schedule.rb @@ -42,6 +42,12 @@ 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 + return unless resource_id + towhat.safe_constantize.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)