diff --git a/railties/lib/rails/generators/rails/app/app_generator.rb b/railties/lib/rails/generators/rails/app/app_generator.rb index aa066fe3c45d7..667a123025bcf 100644 --- a/railties/lib/rails/generators/rails/app/app_generator.rb +++ b/railties/lib/rails/generators/rails/app/app_generator.rb @@ -55,6 +55,7 @@ class AppGenerator < Base :desc => "Show this help message and quit" def initialize(*args) + raise Error, "Options should be given after the application name. For details run: rails --help" if args[0].blank? super if !options[:skip_activerecord] && !DATABASES.include?(options[:database]) raise Error, "Invalid value for --database option. Supported for preconfiguration are: #{DATABASES.join(", ")}." diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb index 24e6d541c2d55..e57b5e19b42f1 100644 --- a/railties/test/generators/app_generator_test.rb +++ b/railties/test/generators/app_generator_test.rb @@ -58,6 +58,11 @@ def test_application_controller_and_layout_files assert_no_file "public/stylesheets/application.css" end + def test_options_before_application_name_raises_an_error + content = capture(:stderr){ run_generator(["--skip-activerecord", destination_root]) } + assert_equal "Options should be given after the application name. For details run: rails --help\n", content + end + def test_name_collision_raises_an_error content = capture(:stderr){ run_generator [File.join(destination_root, "generate")] } assert_equal "Invalid application name generate. Please give a name which does not match one of the reserved rails words.\n", content