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 <HASH>..<HASH> 100644
--- a/railties/lib/rails/generators/rails/app/templates/config/boot.rb
+++ b/railties/lib/rails/generators/rails/app/templates/config/boot.rb
@@ -1,6 +1,9 @@
 require 'rubygems'
+
 # Set up gems listed in the Gemfile.
-if File.exist?(File.expand_path('../../Gemfile', __FILE__))
+gemfile = File.expand_path('../../Gemfile', __FILE__)
+if File.exist?(gemfile)
+  ENV['BUNDLE_GEMFILE'] = gemfile
   require 'bundler'
   Bundler.setup
-end
+end
\ No newline at end of file
Allow a Rails application to be initialized from any directory and not just from inside it (ht: Andre Arko).