From 51e8435e346c3f2f6356342b661231fcaeaa357a Mon Sep 17 00:00:00 2001 From: Fred Wu Date: Mon, 30 Aug 2010 21:53:34 +1000 Subject: Ensures the app generator generates the correct @app_name. [#5434 state:resolved] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: José Valim --- railties/lib/rails/generators/rails/app/app_generator.rb | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (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 cdff1743ff..2715483914 100644 --- a/railties/lib/rails/generators/rails/app/app_generator.rb +++ b/railties/lib/rails/generators/rails/app/app_generator.rb @@ -353,18 +353,21 @@ module Rails end def app_name - @app_name ||= File.basename(destination_root) + @app_name ||= defined_app_const_base? ? defined_app_name : File.basename(destination_root) + end + + def defined_app_name + defined_app_const_base.underscore end - - alias_method :defined_app_name, :app_name def defined_app_const_base Rails.respond_to?(:application) && defined?(Rails::Application) && Rails.application.is_a?(Rails::Application) && Rails.application.class.name.sub(/::Application$/, "") end + alias :defined_app_const_base? :defined_app_const_base + def app_const_base - defined_app_name # ensures the correct app_name if it's already defined @app_const_base ||= defined_app_const_base || app_name.gsub(/\W/, '_').squeeze('_').camelize end -- cgit v1.2.3