diff options
author | Fred Wu <ifredwu@gmail.com> | 2010-08-30 21:53:34 +1000 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-09-24 13:10:26 +0200 |
commit | 51e8435e346c3f2f6356342b661231fcaeaa357a (patch) | |
tree | 2843eb7ef8e14e38c40b3e6f8e273cb340cac1dc /railties/lib/rails/generators | |
parent | 6b3ad0cafc4203b0a171ac3c8be24e1c4402e150 (diff) | |
download | rails-51e8435e346c3f2f6356342b661231fcaeaa357a.tar.gz rails-51e8435e346c3f2f6356342b661231fcaeaa357a.tar.bz2 rails-51e8435e346c3f2f6356342b661231fcaeaa357a.zip |
Ensures the app generator generates the correct @app_name. [#5434 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'railties/lib/rails/generators')
-rw-r--r-- | railties/lib/rails/generators/rails/app/app_generator.rb | 11 |
1 files changed, 7 insertions, 4 deletions
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 |