From b0665345f85e4b7f3b3367ee36fa205e7ff78d12 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Mon, 15 Nov 2010 13:09:05 -0600 Subject: Allow running `rails plugin new` command inside rails application --- railties/lib/rails/commands.rb | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'railties/lib') diff --git a/railties/lib/rails/commands.rb b/railties/lib/rails/commands.rb index e3aa6d7c3e..c8a33c1266 100644 --- a/railties/lib/rails/commands.rb +++ b/railties/lib/rails/commands.rb @@ -12,14 +12,19 @@ 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" + 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 -- cgit v1.2.3