Jelajahi Sumber

Fixed BLAZER_DATABASE_URL required error - closes #62

Andrew Kane 9 tahun lalu
induk
melakukan
030a0bf581
4 mengubah file dengan 11 tambahan dan 7 penghapusan
  1. 4 0
      CHANGELOG.md
  2. 0 6
      app/controllers/blazer/base_controller.rb
  3. 2 1
      lib/blazer.rb
  4. 5 0
      lib/blazer/data_source.rb

+ 4 - 0
CHANGELOG.md

@@ -1,3 +1,7 @@
+## 1.3.6
+
+- Fixed `BLAZER_DATABASE_URL required` error
+
 ## 1.3.5
 
 - Fixed error with checks

+ 0 - 6
app/controllers/blazer/base_controller.rb

@@ -15,14 +15,8 @@ module Blazer
 
     layout "blazer/application"
 
-    before_action :ensure_database_url
-
     private
 
-    def ensure_database_url
-      render text: "BLAZER_DATABASE_URL required" if !ENV["BLAZER_DATABASE_URL"] && !Rails.env.development?
-    end
-
     def process_vars(statement, data_source)
       (@bind_vars ||= []).concat(extract_vars(statement)).uniq!
       @bind_vars.each do |var|

+ 2 - 1
lib/blazer.rb

@@ -6,7 +6,8 @@ require "blazer/data_source"
 require "blazer/engine"
 
 module Blazer
-  class TimeoutNotSupported < StandardError; end
+  class Error < StandardError; end
+  class TimeoutNotSupported < Error; end
 
   class << self
     attr_accessor :audit

+ 5 - 0
lib/blazer/data_source.rb

@@ -7,6 +7,11 @@ module Blazer
     def initialize(id, settings)
       @id = id
       @settings = settings
+
+      unless settings["url"] || Rails.env.development?
+        raise Blazer::Error, "Empty url"
+      end
+
       @connection_model =
         Class.new(Blazer::Connection) do
           def self.name