Business intelligence made simple
Fixed error with Rails 4.1 and below - closes #60
Andrew Kanedbb905252695
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 9f002524..e47d9df1 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -1,3 +1,7 @@+## 1.3.3 [unreleased]++- Fixed error with Rails 4.1 and below+## 1.3.2- Added support for Rails 5diff --git a/app/models/blazer/audit.rb b/app/models/blazer/audit.rbindex fbff8c1c..7d6495e5 100644--- a/app/models/blazer/audit.rb+++ b/app/models/blazer/audit.rb@@ -1,6 +1,6 @@module Blazerclass Audit < ActiveRecord::Base- belongs_to :user, class_name: Blazer.user_class.to_s, required: false- belongs_to :query, required: false+ belongs_to :user, Blazer::BELONGS_TO_OPTIONAL.merge(class_name: Blazer.user_class.to_s)+ belongs_to :query, Blazer::BELONGS_TO_OPTIONALendenddiff --git a/app/models/blazer/query.rb b/app/models/blazer/query.rbindex 8d3109ab..36ce15b8 100644--- a/app/models/blazer/query.rb+++ b/app/models/blazer/query.rb@@ -1,6 +1,6 @@module Blazerclass Query < ActiveRecord::Base- belongs_to :creator, class_name: Blazer.user_class.to_s, required: false if Blazer.user_class+ belongs_to :creator, Blazer::BELONGS_TO_OPTIONAL.merge(class_name: Blazer.user_class.to_s) if Blazer.user_classhas_many :checks, dependent: :destroyhas_many :dashboard_queries, dependent: :destroyhas_many :dashboards, through: :dashboard_queriesdiff --git a/lib/blazer.rb b/lib/blazer.rbindex 386bd912..75fe4fa9 100644--- a/lib/blazer.rb+++ b/lib/blazer.rb@@ -30,6 +30,8 @@ module Blazer"cancelled on user's request", # redshift"system requested abort" # redshift]+ BELONGS_TO_OPTIONAL = {}+ BELONGS_TO_OPTIONAL[:optional] = true if Rails::VERSION::MAJOR >= 5def self.time_zone=(time_zone)@time_zone = time_zone.is_a?(ActiveSupport::TimeZone) ? time_zone : ActiveSupport::TimeZone[time_zone.to_s]diff --git a/lib/blazer/engine.rb b/lib/blazer/engine.rbindex bb307ce3..fcad58bf 100644--- a/lib/blazer/engine.rb+++ b/lib/blazer/engine.rb@@ -22,9 +22,10 @@ module BlazerBlazer.check_schedules = Blazer.settings["check_schedules"] if Blazer.settings.key?("check_schedules")if Blazer.user_class- Blazer::Query.belongs_to :creator, class_name: Blazer.user_class.to_s- Blazer::Dashboard.belongs_to :creator, class_name: Blazer.user_class.to_s- Blazer::Check.belongs_to :creator, class_name: Blazer.user_class.to_s+ options = Blazer::BELONGS_TO_OPTIONAL.merge(class_name: Blazer.user_class.to_s)+ Blazer::Query.belongs_to :creator, options+ Blazer::Dashboard.belongs_to :creator, options+ Blazer::Check.belongs_to :creator, optionsendBlazer.cache ||= Rails.cache