aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/generators/rails/app/app_generator.rb
diff options
context:
space:
mode:
Diffstat (limited to 'railties/lib/generators/rails/app/app_generator.rb')
-rw-r--r--railties/lib/generators/rails/app/app_generator.rb21
1 files changed, 18 insertions, 3 deletions
diff --git a/railties/lib/generators/rails/app/app_generator.rb b/railties/lib/generators/rails/app/app_generator.rb
index c8044d13b1..c80a344e0d 100644
--- a/railties/lib/generators/rails/app/app_generator.rb
+++ b/railties/lib/generators/rails/app/app_generator.rb
@@ -49,7 +49,7 @@ module Rails::Generators
self.destination_root = File.expand_path(app_path, destination_root)
empty_directory '.'
- app_name # Sets the app name
+ set_default_accessors!
FileUtils.cd(destination_root)
end
@@ -164,9 +164,9 @@ module Rails::Generators
end
def apply_rails_template
- apply options[:template] if options[:template]
+ apply rails_template if rails_template
rescue Thor::Error, LoadError, Errno::ENOENT => e
- raise Error, "The template [#{options[:template]}] could not be loaded. Error: #{e}"
+ raise Error, "The template [#{rails_template}] could not be loaded. Error: #{e}"
end
def freeze?
@@ -175,6 +175,21 @@ module Rails::Generators
protected
+ attr_accessor :rails_template
+
+ def set_default_accessors!
+ app_name # Cache app name
+
+ self.rails_template = case options[:template]
+ when /^http:\/\//
+ options[:template]
+ when String
+ File.expand_path(options[:template], Dir.pwd)
+ else
+ options[:template]
+ end
+ end
+
# Define file as an alias to create_file for backwards compatibility.
#
def file(*args, &block)