Module: Racecar::RailsConfigFileLoader

Defined in:
lib/racecar/rails_config_file_loader.rb

Class Method Summary collapse

Class Method Details

.load!Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/racecar/rails_config_file_loader.rb', line 3

def self.load!
  config_file = "config/racecar.yml"

  begin
    require "rails"
  rescue LoadError
    # Not a Rails application.
  end

  if defined?(Rails)
    $stderr.puts "=> Detected Rails, booting application..."

    require "./config/environment"

    if (Rails.root + config_file).readable?
      Racecar.config.load_file(config_file, Rails.env)
    end

    # In development, write Rails logs to STDOUT. This mirrors what e.g.
    # Unicorn does.
    if Rails.env.development? && defined?(ActiveSupport::Logger)
      console = ActiveSupport::Logger.new($stdout)
      console.formatter = Rails.logger.formatter
      console.level = Rails.logger.level
      Rails.logger.extend(ActiveSupport::Logger.broadcast(console))
    end
  end
end