aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
authorPiotr Sarnacki <drogus@gmail.com>2013-09-07 22:50:54 +0200
committerPiotr Sarnacki <drogus@gmail.com>2013-09-13 18:02:25 +0200
commit47ac67b8d4f77e22ce1cae5c7bf836b0d6325d1e (patch)
treed954217147e544d6259711710256d5126fcf0baf /railties
parentca50043a7ad95825b3830d97294b14b665a7d698 (diff)
downloadrails-47ac67b8d4f77e22ce1cae5c7bf836b0d6325d1e.tar.gz
rails-47ac67b8d4f77e22ce1cae5c7bf836b0d6325d1e.tar.bz2
rails-47ac67b8d4f77e22ce1cae5c7bf836b0d6325d1e.zip
Don't require using application_name before options
Before this commit options for `rails new` and `rails plugin new` had to be passed in a strict order, trying to execute a following command: rails new -J path/to/app resulted in an error. This commit fixes the situation and allows to pass path to app anywhere after `new`
Diffstat (limited to 'railties')
-rw-r--r--railties/CHANGELOG.md17
-rw-r--r--railties/lib/rails/generators/app_base.rb4
-rw-r--r--railties/lib/rails/generators/rails/app/app_generator.rb14
-rw-r--r--railties/lib/rails/generators/rails/plugin/plugin_generator.rb6
-rw-r--r--railties/test/generators/shared_generator_tests.rb5
5 files changed, 23 insertions, 23 deletions
diff --git a/railties/CHANGELOG.md b/railties/CHANGELOG.md
index cc9722e59c..797cffc884 100644
--- a/railties/CHANGELOG.md
+++ b/railties/CHANGELOG.md
@@ -1,3 +1,8 @@
+* Don't require passing path to app before options in `rails new`
+ and `rails plugin new`
+
+ *Piotr Sarnacki*
+
* rake notes now searches *.less files
*Josh Crowder*
@@ -5,21 +10,21 @@
* Generate nested route for namespaced controller generated using
`rails g controller`.
Fixes #11532.
-
+
Example:
-
+
rails g controller admin/dashboard index
-
+
# Before:
get "dashboard/index"
-
+
# After:
namespace :admin do
get "dashboard/index"
end
-
+
*Prathamesh Sonpatki*
-
+
* Fix the event name of action_dispatch requests.
*Rafael Mendonça França*
diff --git a/railties/lib/rails/generators/app_base.rb b/railties/lib/rails/generators/app_base.rb
index fb495c918c..6f1b7e2218 100644
--- a/railties/lib/rails/generators/app_base.rb
+++ b/railties/lib/rails/generators/app_base.rb
@@ -18,6 +18,10 @@ module Rails
argument :app_path, type: :string
+ def self.strict_args_position
+ false
+ end
+
def self.add_shared_options_for(name)
class_option :template, type: :string, aliases: '-m',
desc: "Path to some #{name} template (can be a filesystem path or URL)"
diff --git a/railties/lib/rails/generators/rails/app/app_generator.rb b/railties/lib/rails/generators/rails/app/app_generator.rb
index 041bfcb733..cce11ba8bc 100644
--- a/railties/lib/rails/generators/rails/app/app_generator.rb
+++ b/railties/lib/rails/generators/rails/app/app_generator.rb
@@ -151,18 +151,12 @@ module Rails
desc: "Show Rails version number and quit"
def initialize(*args)
- if args[0].blank?
- if args[1].blank?
- # rails new
- raise Error, "Application name should be provided in arguments. For details run: rails --help"
- else
- # rails new --skip-bundle my_new_application
- raise Error, "Options should be given after the application name. For details run: rails --help"
- end
- end
-
super
+ unless app_path
+ raise Error, "Application name should be provided in arguments. For details run: rails --help"
+ end
+
if !options[:skip_active_record] && !DATABASES.include?(options[:database])
raise Error, "Invalid value for --database option. Supported for preconfiguration are: #{DATABASES.join(", ")}."
end
diff --git a/railties/lib/rails/generators/rails/plugin/plugin_generator.rb b/railties/lib/rails/generators/rails/plugin/plugin_generator.rb
index 13f5472ede..97ff6d1b8b 100644
--- a/railties/lib/rails/generators/rails/plugin/plugin_generator.rb
+++ b/railties/lib/rails/generators/rails/plugin/plugin_generator.rb
@@ -176,10 +176,12 @@ task default: :test
"skip adding entry to Gemfile"
def initialize(*args)
- raise Error, "Options should be given after the plugin name. For details run: rails plugin new --help" if args[0].blank?
-
@dummy_path = nil
super
+
+ unless plugin_path
+ raise Error, "Plugin name should be provided in arguments. For details run: rails plugin new --help"
+ end
end
public_task :create_root
diff --git a/railties/test/generators/shared_generator_tests.rb b/railties/test/generators/shared_generator_tests.rb
index 369a0ee46c..7184639d23 100644
--- a/railties/test/generators/shared_generator_tests.rb
+++ b/railties/test/generators/shared_generator_tests.rb
@@ -46,11 +46,6 @@ module SharedGeneratorTests
assert_no_file "test"
end
- def test_options_before_application_name_raises_an_error
- content = capture(:stderr){ run_generator(["--pretend", destination_root]) }
- assert_match(/Options should be given after the \w+ name. For details run: rails( plugin new)? --help\n/, content)
- end
-
def test_name_collision_raises_an_error
reserved_words = %w[application destroy plugin runner test]
reserved_words.each do |reserved|