diff options
| author | erdgeist <erdgeist@erdgeist.org> | 2026-06-24 04:13:16 +0200 |
|---|---|---|
| committer | erdgeist <erdgeist@erdgeist.org> | 2026-06-24 04:13:16 +0200 |
| commit | e0a7e0fec760ba12c8067a37e10c96f1f05876e2 (patch) | |
| tree | d0cf745592a46aee4d4913911fd34c7c24515220 /config/boot.rb | |
| parent | 6424e10be5a89f175a74c71c55660412a169b8b8 (diff) | |
Stage 1 complete: Rails 2.3.5 to Rails 3.2.22.5 upgrade
- Converted plugins to gems (Gemfile)
- Updated config structure (application.rb, boot.rb, environment.rb)
- Converted routes to Rails 3 DSL
- Converted named_scope to scope throughout models
- Converted find(:all, :conditions) to where() chains
- Fixed has_many :order to use ordering scope
- Updated session store and secret token configuration
- Fixed exception_notification middleware configuration
- Patched Ruby 2.4 / Rails 3.2 incompatibilities:
- Integer/Float duration arithmetic (ActiveSupport)
- Arel visit_Integer for PostgreSQL adapter
- create_database String/Integer coercion
- ActionController consider_all_requests_local
- Migrated taggings schema for acts-as-taggable-on
- Replaced dynamic_form gem with custom form_error_messages helper
- Fixed Rails 3 block helper syntax (form_for, form_tag, fields_for)
- Fixed admin layout yield
- Updated test suite for Rails 3 APIs
Diffstat (limited to 'config/boot.rb')
| -rw-r--r-- | config/boot.rb | 113 |
1 files changed, 2 insertions, 111 deletions
diff --git a/config/boot.rb b/config/boot.rb index 9834fc4..b92444f 100644 --- a/config/boot.rb +++ b/config/boot.rb | |||
| @@ -1,111 +1,2 @@ | |||
| 1 | # Don't change this file! | 1 | require 'rubygems' |
| 2 | # Configure your app in config/environment.rb and config/environments/*.rb | 2 | require 'bundler/setup' |
| 3 | |||
| 4 | RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT) | ||
| 5 | ENV['NLS_LANG'] = 'de_DE.UTF8' | ||
| 6 | |||
| 7 | module Rails | ||
| 8 | class << self | ||
| 9 | def boot! | ||
| 10 | unless booted? | ||
| 11 | preinitialize | ||
| 12 | pick_boot.run | ||
| 13 | end | ||
| 14 | end | ||
| 15 | |||
| 16 | def booted? | ||
| 17 | defined? Rails::Initializer | ||
| 18 | end | ||
| 19 | |||
| 20 | def pick_boot | ||
| 21 | (vendor_rails? ? VendorBoot : GemBoot).new | ||
| 22 | end | ||
| 23 | |||
| 24 | def vendor_rails? | ||
| 25 | File.exist?("#{RAILS_ROOT}/vendor/rails") | ||
| 26 | end | ||
| 27 | |||
| 28 | def preinitialize | ||
| 29 | load(preinitializer_path) if File.exist?(preinitializer_path) | ||
| 30 | end | ||
| 31 | |||
| 32 | def preinitializer_path | ||
| 33 | "#{RAILS_ROOT}/config/preinitializer.rb" | ||
| 34 | end | ||
| 35 | end | ||
| 36 | |||
| 37 | class Boot | ||
| 38 | def run | ||
| 39 | load_initializer | ||
| 40 | Rails::Initializer.run(:set_load_path) | ||
| 41 | end | ||
| 42 | end | ||
| 43 | |||
| 44 | class VendorBoot < Boot | ||
| 45 | def load_initializer | ||
| 46 | require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer" | ||
| 47 | Rails::Initializer.run(:install_gem_spec_stubs) | ||
| 48 | Rails::GemDependency.add_frozen_gem_path | ||
| 49 | end | ||
| 50 | end | ||
| 51 | |||
| 52 | class GemBoot < Boot | ||
| 53 | def load_initializer | ||
| 54 | self.class.load_rubygems | ||
| 55 | load_rails_gem | ||
| 56 | require 'initializer' | ||
| 57 | end | ||
| 58 | |||
| 59 | def load_rails_gem | ||
| 60 | if version = self.class.gem_version | ||
| 61 | gem 'rails', version | ||
| 62 | else | ||
| 63 | gem 'rails' | ||
| 64 | end | ||
| 65 | rescue Gem::LoadError => load_error | ||
| 66 | $stderr.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.) | ||
| 67 | exit 1 | ||
| 68 | end | ||
| 69 | |||
| 70 | class << self | ||
| 71 | def rubygems_version | ||
| 72 | Gem::RubyGemsVersion rescue nil | ||
| 73 | end | ||
| 74 | |||
| 75 | def gem_version | ||
| 76 | if defined? RAILS_GEM_VERSION | ||
| 77 | RAILS_GEM_VERSION | ||
| 78 | elsif ENV.include?('RAILS_GEM_VERSION') | ||
| 79 | ENV['RAILS_GEM_VERSION'] | ||
| 80 | else | ||
| 81 | parse_gem_version(read_environment_rb) | ||
| 82 | end | ||
| 83 | end | ||
| 84 | |||
| 85 | def load_rubygems | ||
| 86 | min_version = '1.3.2' | ||
| 87 | require 'rubygems' | ||
| 88 | unless rubygems_version >= min_version | ||
| 89 | $stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.) | ||
| 90 | exit 1 | ||
| 91 | end | ||
| 92 | |||
| 93 | rescue LoadError | ||
| 94 | $stderr.puts %Q(Rails requires RubyGems >= #{min_version}. Please install RubyGems and try again: http://rubygems.rubyforge.org) | ||
| 95 | exit 1 | ||
| 96 | end | ||
| 97 | |||
| 98 | def parse_gem_version(text) | ||
| 99 | $1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/ | ||
| 100 | end | ||
| 101 | |||
| 102 | private | ||
| 103 | def read_environment_rb | ||
| 104 | File.read("#{RAILS_ROOT}/config/environment.rb") | ||
| 105 | end | ||
| 106 | end | ||
| 107 | end | ||
| 108 | end | ||
| 109 | |||
| 110 | # All that for this: | ||
| 111 | Rails.boot! | ||
