diff options
Diffstat (limited to 'railties/lib')
4 files changed, 23 insertions, 16 deletions
diff --git a/railties/lib/rails/generators/rails/app/app_generator.rb b/railties/lib/rails/generators/rails/app/app_generator.rb index 20843cd720..93d9ac553d 100644 --- a/railties/lib/rails/generators/rails/app/app_generator.rb +++ b/railties/lib/rails/generators/rails/app/app_generator.rb @@ -1,4 +1,4 @@ -require 'digest/md5' +require 'digest/md5' require 'active_support/secure_random' require 'rails/version' unless defined?(Rails::VERSION) @@ -75,6 +75,10 @@ module Rails::Generators end end + def create_boot_file + copy_file "config/boot.rb" + end + def create_activerecord_files return if options[:skip_activerecord] template "config/databases/#{options[:database]}.yml", "config/database.yml" diff --git a/railties/lib/rails/generators/rails/app/templates/config/application.rb b/railties/lib/rails/generators/rails/app/templates/config/application.rb index 451dba86fb..7ba7c52f9e 100644 --- a/railties/lib/rails/generators/rails/app/templates/config/application.rb +++ b/railties/lib/rails/generators/rails/app/templates/config/application.rb @@ -1,12 +1,4 @@ -begin - # Use Bundler - require File.expand_path("../../vendor/gems/environment", __FILE__) -rescue LoadError - # Use Rubygems - require 'rubygems' -end - -require 'rails' +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. @@ -52,4 +44,4 @@ Rails::Initializer.run do |config| # g.template_engine :erb # g.test_framework :test_unit, :fixture => true # end -end
\ No newline at end of file +end diff --git a/railties/lib/rails/generators/rails/app/templates/config/boot.rb b/railties/lib/rails/generators/rails/app/templates/config/boot.rb new file mode 100644 index 0000000000..3165a4091e --- /dev/null +++ b/railties/lib/rails/generators/rails/app/templates/config/boot.rb @@ -0,0 +1,15 @@ +# Package management +# Choose one + +# Use Bundler (preferred) +environment = File.expand_path('../../vendor/gems/environment', __FILE__) +require environment if File.exist?(environment) + +# Use 2.x style vendor/rails directory +vendor_rails = File.expand_path('../../vendor/rails', __FILE__) +Dir["#{vendor_rails}/*/lib"].each { |path| $:.unshift(path) } if File.exist?(vendor_rails) + +# Load Rails from traditional RubyGems +require 'rubygems' + +require 'rails' 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 3bb0f2619e..e5362b21cc 100644 --- a/railties/lib/rails/generators/rails/app/templates/config/environment.rb +++ b/railties/lib/rails/generators/rails/app/templates/config/environment.rb @@ -1,9 +1,5 @@ -# Be sure to restart your server when you modify this file - -# 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 - # Load the rails application require File.expand_path(File.join(File.dirname(__FILE__), 'application')) + # Initialize the rails application Rails.initialize! |