Changeset 70
- Timestamp:
- 01/07/08 17:39:33 (11 months ago)
- Location:
- trunk/config
- Files:
-
- 3 added
- 2 modified
-
boot.rb (modified) (1 diff)
-
environment.rb (modified) (4 diffs)
-
initializers (added)
-
initializers/inflections.rb (added)
-
initializers/mime_types.rb (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/config/boot.rb
r1 r70 1 # Don't change this file. Configuration is done in config/environment.rb and config/environments/*.rb 1 # Don't change this file! 2 # Configure your app in config/environment.rb and config/environments/*.rb 2 3 3 4 RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT) 4 5 5 unless defined?(Rails::Initializer) 6 if File.directory?("#{RAILS_ROOT}/vendor/rails") 7 require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer" 8 else 9 require 'rubygems' 6 module Rails 7 class << self 8 def boot! 9 unless booted? 10 preinitialize 11 pick_boot.run 12 end 13 end 10 14 11 environment_without_comments = IO.readlines(File.dirname(__FILE__) + '/environment.rb').reject { |l| l =~ /^#/ }.join12 environment_without_comments =~ /[^#]RAILS_GEM_VERSION = '([\d.]+)'/13 rails_gem_version = $115 def booted? 16 defined? Rails::Initializer 17 end 14 18 15 if version = defined?(RAILS_GEM_VERSION) ? RAILS_GEM_VERSION : rails_gem_version16 # Asking for 1.1.6 will give you 1.1.6.5206, if available -- makes it easier to use beta gems17 rails_gem = Gem.cache.search('rails', "~>#{version}.0").sort_by { |g| g.version.version }.last19 def pick_boot 20 (vendor_rails? ? VendorBoot : GemBoot).new 21 end 18 22 19 if rails_gem 20 gem "rails", "=#{rails_gem.version.version}" 21 require rails_gem.full_gem_path + '/lib/initializer' 22 else 23 STDERR.puts %(Cannot find gem for Rails ~>#{version}.0: 24 Install the missing gem with 'gem install -v=#{version} rails', or 25 change environment.rb to define RAILS_GEM_VERSION with your desired version. 26 ) 27 exit 1 28 end 29 else 30 gem "rails" 31 require 'initializer' 23 def vendor_rails? 24 File.exist?("#{RAILS_ROOT}/vendor/rails") 25 end 26 27 def preinitialize 28 load(preinitializer_path) if File.exists?(preinitializer_path) 29 end 30 31 def preinitializer_path 32 "#{RAILS_ROOT}/config/preinitializer.rb" 32 33 end 33 34 end 34 35 35 Rails::Initializer.run(:set_load_path) 36 class Boot 37 def run 38 load_initializer 39 Rails::Initializer.run(:set_load_path) 40 end 41 end 42 43 class VendorBoot < Boot 44 def load_initializer 45 require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer" 46 end 47 end 48 49 class GemBoot < Boot 50 def load_initializer 51 self.class.load_rubygems 52 load_rails_gem 53 require 'initializer' 54 end 55 56 def load_rails_gem 57 if version = self.class.gem_version 58 gem 'rails', version 59 else 60 gem 'rails' 61 end 62 rescue Gem::LoadError => load_error 63 $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.) 64 exit 1 65 end 66 67 class << self 68 def rubygems_version 69 Gem::RubyGemsVersion if defined? Gem::RubyGemsVersion 70 end 71 72 def gem_version 73 if defined? RAILS_GEM_VERSION 74 RAILS_GEM_VERSION 75 elsif ENV.include?('RAILS_GEM_VERSION') 76 ENV['RAILS_GEM_VERSION'] 77 else 78 parse_gem_version(read_environment_rb) 79 end 80 end 81 82 def load_rubygems 83 require 'rubygems' 84 85 unless rubygems_version >= '0.9.4' 86 $stderr.puts %(Rails requires RubyGems >= 0.9.4 (you have #{rubygems_version}). Please `gem update --system` and try again.) 87 exit 1 88 end 89 90 rescue LoadError 91 $stderr.puts %(Rails requires RubyGems >= 0.9.4. Please install RubyGems and try again: http://rubygems.rubyforge.org) 92 exit 1 93 end 94 95 def parse_gem_version(text) 96 $1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*'([!~<>=]*\s*[\d.]+)'/ 97 end 98 99 private 100 def read_environment_rb 101 File.read("#{RAILS_ROOT}/config/environment.rb") 102 end 103 end 104 end 36 105 end 106 107 # All that for this: 108 Rails.boot! -
trunk/config/environment.rb
r63 r70 1 # Be sure to restart your web server when you modify this file.1 # Be sure to restart your server when you modify this file 2 2 3 # Uncomment below to force Rails into production mode when 3 # Uncomment below to force Rails into production mode when 4 4 # you don't control web/app server and can't set it the proper way 5 5 # ENV['RAILS_ENV'] ||= 'production' … … 12 12 13 13 Rails::Initializer.run do |config| 14 # Settings in config/environments/* take precedence over those specified here 14 # Settings in config/environments/* take precedence over those specified here. 15 # Application configuration should go into files in config/initializers 16 # -- all .rb files in that directory are automatically loaded. 17 # See Rails::Configuration for more options. 15 18 16 # Skip frameworks you're not going to use (only works if using vendor/rails) 17 # config.frameworks -= [ :active_resource, :action_mailer ] 19 # Skip frameworks you're not going to use (only works if using vendor/rails). 20 # To use Rails without a database, you must remove the Active Record framework 21 # config.frameworks -= [ :active_record, :active_resource, :action_mailer ] 18 22 19 # Only load the plugins named here, by default all plugins in vendor/plugins are loaded 20 # config.plugins = %W( exception_notification ssl_requirement ) 23 # Only load the plugins named here, in the order given. By default, all plugins 24 # in vendor/plugins are loaded in alphabetical order. 25 # :all can be used as a placeholder for all plugins not explicitly named 26 # config.plugins = [ :exception_notification, :ssl_requirement, :all ] 21 27 22 28 # Add additional load paths for your own custom dirs … … 29 35 # Your secret key for verifying cookie session data integrity. 30 36 # If you change this key, all old sessions will become invalid! 37 # Make sure the secret is at least 30 characters and all random, 38 # no regular words or you'll be exposed to dictionary attacks. 31 39 config.action_controller.session = { 32 :session_key => '_ test_session',33 :secret => ' c856f89ddabee3fc3a14e358a3e9035c'40 :session_key => '_webistrano_session', 41 :secret => '4a850072e0e38kvi8#e3abcbf3e0702f0c0cfab35c7e29cbee5e6f267cd8b652ffa24jkasjdh78jk3-0a9:~&@90fb7759e073f0f6ba4b0607bc10324c' 34 42 } 35 43 36 # Use the database for sessions instead of the file system 44 # Use the database for sessions instead of the cookie-based default, 45 # which shouldn't be used to store highly confidential information 37 46 # (create the session table with 'rake db:sessions:create') 38 47 # config.action_controller.session_store = :active_record_store … … 48 57 # Make Active Record use UTC-base instead of local time 49 58 config.active_record.default_timezone = :utc 50 51 # See Rails::Configuration for more options52 53 # Application configuration should go into files in config/initializers54 # -- all .rb files in that directory is automatically loaded55 59 end 56 60
