diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2009-10-15 17:36:54 -0700 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2009-10-15 17:36:54 -0700 |
commit | 71f7e75d95c47e4283a7cac0a2f776abf0a11d0e (patch) | |
tree | 75a9b6825f9f81a9bec372af8db097b6ea022fc6 /railties/lib | |
parent | 2d7abe245e7a2b1717e48ef550e4083318fd7ec2 (diff) | |
parent | ef70ad5538c4ce02c4d31ef01a8db6b55c837571 (diff) | |
download | rails-71f7e75d95c47e4283a7cac0a2f776abf0a11d0e.tar.gz rails-71f7e75d95c47e4283a7cac0a2f776abf0a11d0e.tar.bz2 rails-71f7e75d95c47e4283a7cac0a2f776abf0a11d0e.zip |
Merge branch 'master' into orchestra
Diffstat (limited to 'railties/lib')
24 files changed, 73 insertions, 69 deletions
diff --git a/railties/lib/rails/commands/about.rb b/railties/lib/rails/commands/about.rb index bc2cfcb948..9a05c47390 100644 --- a/railties/lib/rails/commands/about.rb +++ b/railties/lib/rails/commands/about.rb @@ -1,3 +1,4 @@ -require "#{RAILS_ROOT}/config/environment" +require "#{RAILS_ROOT}/config/application" +Rails.application.new require 'rails/info' puts Rails::Info diff --git a/railties/lib/rails/commands/destroy.rb b/railties/lib/rails/commands/destroy.rb index 5013d30b83..860c03e01e 100644 --- a/railties/lib/rails/commands/destroy.rb +++ b/railties/lib/rails/commands/destroy.rb @@ -1,5 +1,5 @@ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'generators')) -require "#{RAILS_ROOT}/config/environment" +require "#{RAILS_ROOT}/config/application" if ARGV.size == 0 Rails::Generators.help diff --git a/railties/lib/rails/commands/generate.rb b/railties/lib/rails/commands/generate.rb index 32cabcab10..cfa6a51d94 100755 --- a/railties/lib/rails/commands/generate.rb +++ b/railties/lib/rails/commands/generate.rb @@ -1,5 +1,5 @@ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'generators')) -require "#{RAILS_ROOT}/config/environment" +Rails.application.new if ARGV.size == 0 Rails::Generators.help diff --git a/railties/lib/rails/commands/performance/benchmarker.rb b/railties/lib/rails/commands/performance/benchmarker.rb index e8804fe1bf..5039c5408c 100644 --- a/railties/lib/rails/commands/performance/benchmarker.rb +++ b/railties/lib/rails/commands/performance/benchmarker.rb @@ -10,9 +10,9 @@ rescue ArgumentError N = 1 end -require RAILS_ROOT + '/config/environment' require 'benchmark' include Benchmark +Rails.application.new # Don't include compilation in the benchmark ARGV.each { |expression| eval(expression) } diff --git a/railties/lib/rails/commands/performance/profiler.rb b/railties/lib/rails/commands/performance/profiler.rb index 7df840f197..7274e2dfb7 100644 --- a/railties/lib/rails/commands/performance/profiler.rb +++ b/railties/lib/rails/commands/performance/profiler.rb @@ -5,7 +5,7 @@ end # Keep the expensive require out of the profile. $stderr.puts 'Loading Rails...' -require RAILS_ROOT + '/config/environment' +Rails.application.new # Initialize the application # Define a method to profile. if ARGV[1] and ARGV[1].to_i > 1 diff --git a/railties/lib/rails/commands/runner.rb b/railties/lib/rails/commands/runner.rb index 510128318a..d24f36dd63 100644 --- a/railties/lib/rails/commands/runner.rb +++ b/railties/lib/rails/commands/runner.rb @@ -36,7 +36,7 @@ ARGV.delete(code_or_file) ENV["RAILS_ENV"] = options[:environment] RAILS_ENV.replace(options[:environment]) if defined?(RAILS_ENV) -require RAILS_ROOT + '/config/environment' +Rails.application.new begin if code_or_file.nil? diff --git a/railties/lib/rails/commands/update.rb b/railties/lib/rails/commands/update.rb index f3b3ad0775..85a81cddf0 100644 --- a/railties/lib/rails/commands/update.rb +++ b/railties/lib/rails/commands/update.rb @@ -1,5 +1,4 @@ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'generators')) -require "#{RAILS_ROOT}/config/environment" if ARGV.size == 0 Rails::Generators.help diff --git a/railties/lib/rails/generators/actions.rb b/railties/lib/rails/generators/actions.rb index c4552dd399..9254f8d918 100644 --- a/railties/lib/rails/generators/actions.rb +++ b/railties/lib/rails/generators/actions.rb @@ -71,7 +71,7 @@ module Rails in_root do if options[:env].nil? - inject_into_file 'config/environment.rb', "\n #{data}", :after => sentinel, :verbose => false + inject_into_file 'config/application.rb', "\n #{data}", :after => sentinel, :verbose => false else Array.wrap(options[:env]).each do|env| append_file "config/environments/#{env}.rb", "\n#{data}", :verbose => false diff --git a/railties/lib/rails/generators/rails/app/app_generator.rb b/railties/lib/rails/generators/rails/app/app_generator.rb index bd7af25bd5..49b13cae2b 100644 --- a/railties/lib/rails/generators/rails/app/app_generator.rb +++ b/railties/lib/rails/generators/rails/app/app_generator.rb @@ -66,6 +66,7 @@ module Rails::Generators inside "config" do copy_file "routes.rb" + template "application.rb" template "environment.rb" directory "environments" diff --git a/railties/lib/rails/generators/rails/app/templates/Rakefile b/railties/lib/rails/generators/rails/app/templates/Rakefile index bd4dec5389..1dce9863f2 100755 --- a/railties/lib/rails/generators/rails/app/templates/Rakefile +++ b/railties/lib/rails/generators/rails/app/templates/Rakefile @@ -1,7 +1,7 @@ # Add your own tasks in files placed in lib/tasks ending in .rake, # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. -require(File.join(File.dirname(__FILE__), 'config', 'boot')) +require File.expand_path(File.join(File.dirname(__FILE__), 'config', 'environment')) require 'rake' require 'rake/testtask' diff --git a/railties/lib/rails/generators/rails/app/templates/config.ru b/railties/lib/rails/generators/rails/app/templates/config.ru index 50ee033d44..3702ad0466 100644 --- a/railties/lib/rails/generators/rails/app/templates/config.ru +++ b/railties/lib/rails/generators/rails/app/templates/config.ru @@ -1,5 +1,5 @@ # Require your environment file to bootstrap Rails -require ::File.dirname(__FILE__) + '/config/environment' +require File.expand_path('../config/application', __FILE__) # Dispatch the request run Rails.application.new diff --git a/railties/lib/rails/generators/rails/app/templates/config/application.rb b/railties/lib/rails/generators/rails/app/templates/config/application.rb new file mode 100644 index 0000000000..bff74a7786 --- /dev/null +++ b/railties/lib/rails/generators/rails/app/templates/config/application.rb @@ -0,0 +1,48 @@ +# Bootstrap the Rails environment, frameworks, and default configuration +require File.expand_path(File.join(File.dirname(__FILE__), 'boot')) + +Rails::Initializer.run do |config| + # Settings in config/environments/* take precedence over those specified here. + # Application configuration should go into files in config/initializers + # -- all .rb files in that directory are automatically loaded. + + # Add additional load paths for your own custom dirs + # config.load_paths += %W( #{RAILS_ROOT}/extras ) + + # Specify gems that this application depends on and have them installed with rake gems:install + # config.gem "bj" + # config.gem "hpricot", :version => '0.6', :source => "http://code.whytheluckystiff.net" + # config.gem "sqlite3-ruby", :lib => "sqlite3" + # config.gem "aws-s3", :lib => "aws/s3" + + # Only load the plugins named here, in the order given (default is alphabetical). + # :all can be used as a placeholder for all plugins not explicitly named + # config.plugins = [ :exception_notification, :ssl_requirement, :all ] + + # Skip frameworks you're not going to use. To use Rails without a database, + # you must remove the Active Record framework. +<% if options[:skip_activerecord] -%> + config.frameworks -= [ :active_record ] +<% else -%> + # config.frameworks -= [ :active_record, :active_resource, :action_mailer ] + + # Activate observers that should always be running + # config.active_record.observers = :cacher, :garbage_collector, :forum_observer +<% end -%> + + # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. + # Run "rake -D time" for a list of tasks for finding time zone names. + config.time_zone = 'UTC' + + # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. + # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}')] + # config.i18n.default_locale = :de + + # Configure generators values. Many other options are available, be sure to + # check the documentation. + # config.generators do |g| + # g.orm :active_record + # g.template_engine :erb + # g.test_framework :test_unit, :fixture => true + # end +end
\ No newline at end of file diff --git a/railties/lib/rails/generators/rails/app/templates/config/environment.rb b/railties/lib/rails/generators/rails/app/templates/config/environment.rb index adb3a3060a..fcf4eddb00 100644 --- a/railties/lib/rails/generators/rails/app/templates/config/environment.rb +++ b/railties/lib/rails/generators/rails/app/templates/config/environment.rb @@ -3,51 +3,7 @@ # Specifies gem version of Rails to use when vendor/rails is not present <%= '# ' if options[:freeze] %>RAILS_GEM_VERSION = '<%= Rails::VERSION::STRING %>' unless defined? RAILS_GEM_VERSION -# Bootstrap the Rails environment, frameworks, and default configuration -require File.join(File.dirname(__FILE__), 'boot') - -Rails::Initializer.run do |config| - # Settings in config/environments/* take precedence over those specified here. - # Application configuration should go into files in config/initializers - # -- all .rb files in that directory are automatically loaded. - - # Add additional load paths for your own custom dirs - # config.load_paths += %W( #{RAILS_ROOT}/extras ) - - # Specify gems that this application depends on and have them installed with rake gems:install - # config.gem "bj" - # config.gem "hpricot", :version => '0.6', :source => "http://code.whytheluckystiff.net" - # config.gem "sqlite3-ruby", :lib => "sqlite3" - # config.gem "aws-s3", :lib => "aws/s3" - - # Only load the plugins named here, in the order given (default is alphabetical). - # :all can be used as a placeholder for all plugins not explicitly named - # config.plugins = [ :exception_notification, :ssl_requirement, :all ] - - # Skip frameworks you're not going to use. To use Rails without a database, - # you must remove the Active Record framework. -<% if options[:skip_activerecord] -%> - config.frameworks -= [ :active_record ] -<% else -%> - # config.frameworks -= [ :active_record, :active_resource, :action_mailer ] - - # Activate observers that should always be running - # config.active_record.observers = :cacher, :garbage_collector, :forum_observer -<% end -%> - - # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. - # Run "rake -D time" for a list of tasks for finding time zone names. - config.time_zone = 'UTC' - - # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. - # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}')] - # config.i18n.default_locale = :de - - # Configure generators values. Many other options are available, be sure to - # check the documentation. - # config.generators do |g| - # g.orm :active_record - # g.template_engine :erb - # g.test_framework :test_unit, :fixture => true - # end -end +# Load the rails application +require File.expand_path(File.join(File.dirname(__FILE__), 'application')) +# Initialize the rails application +Rails.application.new diff --git a/railties/lib/rails/generators/rails/app/templates/script/about.tt b/railties/lib/rails/generators/rails/app/templates/script/about.tt index 1220676c08..90a320297e 100755 --- a/railties/lib/rails/generators/rails/app/templates/script/about.tt +++ b/railties/lib/rails/generators/rails/app/templates/script/about.tt @@ -1,4 +1,4 @@ <%= shebang %> -require File.expand_path('../../config/boot', __FILE__) +require File.expand_path('../../config/application', __FILE__) $LOAD_PATH.unshift "#{RAILTIES_PATH}/builtin/rails_info" require 'rails/commands/about' diff --git a/railties/lib/rails/generators/rails/app/templates/script/console.tt b/railties/lib/rails/generators/rails/app/templates/script/console.tt index 5aec193853..1cd2eb8b53 100755 --- a/railties/lib/rails/generators/rails/app/templates/script/console.tt +++ b/railties/lib/rails/generators/rails/app/templates/script/console.tt @@ -1,3 +1,3 @@ <%= shebang %> -require File.expand_path('../../config/boot', __FILE__) +require File.expand_path('../../config/application', __FILE__) require 'rails/commands/console' diff --git a/railties/lib/rails/generators/rails/app/templates/script/dbconsole.tt b/railties/lib/rails/generators/rails/app/templates/script/dbconsole.tt index 632563f470..94beb13715 100755 --- a/railties/lib/rails/generators/rails/app/templates/script/dbconsole.tt +++ b/railties/lib/rails/generators/rails/app/templates/script/dbconsole.tt @@ -1,3 +1,3 @@ <%= shebang %> -require File.expand_path('../../config/boot', __FILE__) +require File.expand_path('../../config/application', __FILE__) require 'rails/commands/dbconsole' diff --git a/railties/lib/rails/generators/rails/app/templates/script/destroy.tt b/railties/lib/rails/generators/rails/app/templates/script/destroy.tt index c5f94862c3..c97090cdee 100755 --- a/railties/lib/rails/generators/rails/app/templates/script/destroy.tt +++ b/railties/lib/rails/generators/rails/app/templates/script/destroy.tt @@ -1,3 +1,3 @@ <%= shebang %> -require File.expand_path('../../config/boot', __FILE__) +require File.expand_path('../../config/application', __FILE__) require 'rails/commands/destroy' diff --git a/railties/lib/rails/generators/rails/app/templates/script/generate.tt b/railties/lib/rails/generators/rails/app/templates/script/generate.tt index d466c94767..2a9d219531 100755 --- a/railties/lib/rails/generators/rails/app/templates/script/generate.tt +++ b/railties/lib/rails/generators/rails/app/templates/script/generate.tt @@ -1,3 +1,3 @@ <%= shebang %> -require File.expand_path('../../config/boot', __FILE__) +require File.expand_path('../../config/application', __FILE__) require 'rails/commands/generate' diff --git a/railties/lib/rails/generators/rails/app/templates/script/performance/benchmarker.tt b/railties/lib/rails/generators/rails/app/templates/script/performance/benchmarker.tt index 3e03aaa767..90aca9b4e9 100755 --- a/railties/lib/rails/generators/rails/app/templates/script/performance/benchmarker.tt +++ b/railties/lib/rails/generators/rails/app/templates/script/performance/benchmarker.tt @@ -1,3 +1,3 @@ <%= shebang %> -require File.expand_path('../../../config/boot', __FILE__) +require File.expand_path('../../../config/application', __FILE__) require 'rails/commands/performance/benchmarker' diff --git a/railties/lib/rails/generators/rails/app/templates/script/performance/profiler.tt b/railties/lib/rails/generators/rails/app/templates/script/performance/profiler.tt index deada2f561..39569b4e70 100755 --- a/railties/lib/rails/generators/rails/app/templates/script/performance/profiler.tt +++ b/railties/lib/rails/generators/rails/app/templates/script/performance/profiler.tt @@ -1,3 +1,3 @@ <%= shebang %> -require File.expand_path('../../../config/boot', __FILE__) +require File.expand_path('../../../config/application', __FILE__) require 'rails/commands/performance/profiler' diff --git a/railties/lib/rails/generators/rails/app/templates/script/plugin.tt b/railties/lib/rails/generators/rails/app/templates/script/plugin.tt index f4081f56b6..4a335ee33c 100755 --- a/railties/lib/rails/generators/rails/app/templates/script/plugin.tt +++ b/railties/lib/rails/generators/rails/app/templates/script/plugin.tt @@ -1,3 +1,3 @@ <%= shebang %> -require File.expand_path('../../config/boot', __FILE__) +require File.expand_path('../../config/application', __FILE__) require 'rails/commands/plugin' diff --git a/railties/lib/rails/generators/rails/app/templates/script/runner.tt b/railties/lib/rails/generators/rails/app/templates/script/runner.tt index 60c8c0bba1..872ec07a1e 100755 --- a/railties/lib/rails/generators/rails/app/templates/script/runner.tt +++ b/railties/lib/rails/generators/rails/app/templates/script/runner.tt @@ -1,3 +1,3 @@ <%= shebang %> -require File.expand_path('../../config/boot', __FILE__) +require File.expand_path('../../config/application', __FILE__) require 'rails/commands/runner' diff --git a/railties/lib/rails/generators/rails/app/templates/script/server.tt b/railties/lib/rails/generators/rails/app/templates/script/server.tt index 54e3346bec..932e72ea58 100755 --- a/railties/lib/rails/generators/rails/app/templates/script/server.tt +++ b/railties/lib/rails/generators/rails/app/templates/script/server.tt @@ -1,3 +1,3 @@ <%= shebang %> -require File.expand_path('../../config/boot', __FILE__) +require File.expand_path('../../config/application', __FILE__) require 'rails/commands/server' diff --git a/railties/lib/rails/initializer.rb b/railties/lib/rails/initializer.rb index f7c3774450..bb86f70da6 100644 --- a/railties/lib/rails/initializer.rb +++ b/railties/lib/rails/initializer.rb @@ -21,7 +21,6 @@ module Rails else Rails.application = Class.new(Application) yield Rails.application.config if block_given? - Rails.application.new end end end |