Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Ensures the app generator generates the correct @app_name. [#5434 sta…

…te:resolved]

Signed-off-by: José Valim <jose.valim@gmail.com>
  • Loading branch information...
commit 51e8435e346c3f2f6356342b661231fcaeaa357a 1 parent 6b3ad0c
Fred Wu fredwu authored josevalim committed
11 railties/lib/rails/generators/rails/app/app_generator.rb
View
@@ -353,18 +353,21 @@ def file(*args, &block)
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
1  railties/test/generators/app_generator_test.rb
View
@@ -129,6 +129,7 @@ def test_application_name_is_detected_if_it_exists_and_app_folder_renamed
generator.send(:app_const)
silence(:stdout){ generator.send(:create_config_files) }
assert_file "myapp_moved/config/environment.rb", /Myapp::Application\.initialize!/
+ assert_file "myapp_moved/config/initializers/session_store.rb", /_myapp_session/
end
def test_rails_update_generates_correct_session_key
Please sign in to comment.
Something went wrong with that request. Please try again.