aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
Diffstat (limited to 'railties')
-rw-r--r--railties/lib/rails/generators/rails/app/app_generator.rb6
-rw-r--r--railties/lib/rails/generators/rails/app/templates/config/application.rb7
-rw-r--r--railties/lib/rails/generators/rails/app/templates/config/boot.rb16
3 files changed, 15 insertions, 14 deletions
diff --git a/railties/lib/rails/generators/rails/app/app_generator.rb b/railties/lib/rails/generators/rails/app/app_generator.rb
index 0af7f2aa56..fbad3c9ef1 100644
--- a/railties/lib/rails/generators/rails/app/app_generator.rb
+++ b/railties/lib/rails/generators/rails/app/app_generator.rb
@@ -31,8 +31,8 @@ module Rails::Generators
class_option :edge, :type => :boolean, :default => false,
:desc => "Setup the application with Gemfile pointing to Rails repository"
- class_option :skip_bundler, :type => :boolean, :default => false,
- :desc => "Skip Bundler files"
+ class_option :skip_gemfile, :type => :boolean, :default => false,
+ :desc => "Don't create a Gemfile"
class_option :skip_activerecord, :type => :boolean, :aliases => "-O", :default => false,
:desc => "Skip ActiveRecord files"
@@ -74,7 +74,7 @@ module Rails::Generators
copy_file "gitignore", ".gitignore" unless options[:skip_git]
template "Rakefile"
template "config.ru"
- template "Gemfile" unless options[:skip_bundler]
+ template "Gemfile" unless options[:skip_gemfile]
end
def create_app_files
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 a355aac7a6..bd4fedcdec 100644
--- a/railties/lib/rails/generators/rails/app/templates/config/application.rb
+++ b/railties/lib/rails/generators/rails/app/templates/config/application.rb
@@ -11,11 +11,10 @@ require "active_resource/railtie"
require "rails/test_unit/railtie"
<% end -%>
-<% unless options[:skip_bundler] -%>
-# Auto-require default libraries and those for the current Rails environment.
-Bundler.require :default, Rails.env
+# If you have a Gemfile, require the gems listed there, including any gems
+# you've limited to :test, :development, or :production.
+Bundler.require(:default, Rails.env) if defined?(Bundler)
-<% end -%>
module <%= app_const_base %>
class Application < Rails::Application
# Settings in config/environments/* take precedence over those specified here.
diff --git a/railties/lib/rails/generators/rails/app/templates/config/boot.rb b/railties/lib/rails/generators/rails/app/templates/config/boot.rb
index 0c7ae74b0a..809fef02c1 100644
--- a/railties/lib/rails/generators/rails/app/templates/config/boot.rb
+++ b/railties/lib/rails/generators/rails/app/templates/config/boot.rb
@@ -1,12 +1,14 @@
-<% if options[:skip_bundler] -%>
-require 'rubygems'
-<% else -%>
-# Use Bundler (preferred)
+# Use locked gems if present.
begin
require File.expand_path('../../.bundle/environment', __FILE__)
+
rescue LoadError
+ # Otherwise, use RubyGems.
require 'rubygems'
- require 'bundler'
- Bundler.setup
+
+ # And set up the gems listed in the Gemfile.
+ if File.exist?(File.expand_path('../../Gemfile'))
+ require 'bundler'
+ Bundler.setup
+ end
end
-<% end -%>