diff options
Diffstat (limited to 'railties/lib/rails/commands.rb')
-rw-r--r-- | railties/lib/rails/commands.rb | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/railties/lib/rails/commands.rb b/railties/lib/rails/commands.rb index e3aa6d7c3e..de5d876c18 100644 --- a/railties/lib/rails/commands.rb +++ b/railties/lib/rails/commands.rb @@ -12,14 +12,22 @@ command = aliases[command] || command case command when 'generate', 'destroy', 'plugin' - require APP_PATH - Rails.application.require_environment! + if command == "plugin" && ARGV.first == "new" + require "rails/commands/plugin_new" + elsif command == 'generate' && ARGV.first == "plugin_new" + puts "This generator should not be used directly as a generator. You should use `rails plugin new` command instead" + exit(1) + else + require APP_PATH + Rails.application.require_environment! - if defined?(ENGINE_PATH) - engine = Rails.application.railties.engines.find { |r| r.root.to_s == ENGINE_PATH } - Rails.application = engine + if defined?(ENGINE_PATH) + engine = Rails.application.railties.engines.find { |r| r.root.to_s == ENGINE_PATH } + Rails.application = engine + end + + require "rails/commands/#{command}" end - require "rails/commands/#{command}" when 'benchmarker', 'profiler' require APP_PATH |