aboutsummaryrefslogtreecommitdiffstats
path: root/railties/environments/boot.rb
blob: ff4266ac8aabfc8d44c6d7a5377c953ca7e4b29e (plain) (blame)
1
2
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
31
32
33
34
35
36
37
38
# Don't change this file. Configuration is done in config/environment.rb and config/environments/*.rb

unless defined?(RAILS_ROOT)
  root_path = File.join(File.dirname(__FILE__), '..')
  unless RUBY_PLATFORM =~ /mswin32/
    require 'pathname'
    root_path = Pathname.new(root_path).cleanpath(true).to_s
  end
  RAILS_ROOT = root_path
end

if File.directory?("#{RAILS_ROOT}/vendor/rails")
  require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
else
  require 'rubygems'

  if !defined?(RAILS_GEM_VERSION) && File.read(File.dirname(__FILE__) + '/environment.rb') =~ /RAILS_GEM_VERSION = '([\d.]+)'/
    RAILS_GEM_VERSION = $1
  end

  if defined?(RAILS_GEM_VERSION)
    rails_gem = Gem.cache.search('rails', "=#{RAILS_GEM_VERSION}").first

    if rails_gem
      require rails_gem.full_gem_path + '/lib/initializer'
    else
      STDERR.puts %(Cannot find gem for Rails =#{RAILS_GEM_VERSION}:
  Install the missing gem with 'gem install -v=#{RAILS_GEM_VERSION} rails', or
  change environment.rb to define RAILS_GEM_VERSION with your desired version.
)
      exit 1
    end
  else
    require 'initializer'
  end
end

Rails::Initializer.run(:set_load_path)