From cdad483dff4fef1b640dc3c750719c325b252f89 Mon Sep 17 00:00:00 2001 From: Fred Wu Date: Wed, 28 Jul 2010 22:55:57 +1000 Subject: Improved how AppGenerator generates the application name. It now detects the current app name whenever possible. This means that renaming the residing directory will not effect the app name generated by AppGenerator. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [#5225 state:resolved] Signed-off-by: José Valim --- railties/lib/rails/generators/rails/app/app_generator.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'railties/lib/rails') diff --git a/railties/lib/rails/generators/rails/app/app_generator.rb b/railties/lib/rails/generators/rails/app/app_generator.rb index 96c49a81bb..dd18588b39 100644 --- a/railties/lib/rails/generators/rails/app/app_generator.rb +++ b/railties/lib/rails/generators/rails/app/app_generator.rb @@ -356,8 +356,12 @@ module Rails @app_name ||= File.basename(destination_root) end + def defined_app_const_base + Rails.application.class.name.sub(/::Application$/, "") if Rails.application.instance_of?(Rails::Application) + end + def app_const_base - @app_const_base ||= app_name.gsub(/\W/, '_').squeeze('_').camelize + @app_const_base ||= defined_app_const_base || app_name.gsub(/\W/, '_').squeeze('_').camelize end def app_const -- cgit v1.2.3