From 3022ce4f723075d201d9a20f7bca3537aa76a7d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Thu, 7 Jan 2010 21:24:50 +0100 Subject: [PATCH] No more hacks to ensure generators are executed inside Rails.root. --- railties/lib/rails/commands/destroy.rb | 2 +- railties/lib/rails/commands/generate.rb | 2 +- railties/lib/rails/generators/base.rb | 17 ----------------- 3 files changed, 2 insertions(+), 19 deletions(-) diff --git a/railties/lib/rails/commands/destroy.rb b/railties/lib/rails/commands/destroy.rb index f85c17bb94..a2eff377ce 100644 --- a/railties/lib/rails/commands/destroy.rb +++ b/railties/lib/rails/commands/destroy.rb @@ -7,4 +7,4 @@ if ARGV.size == 0 end name = ARGV.shift -Rails::Generators.invoke name, ARGV, :behavior => :revoke +Rails::Generators.invoke name, ARGV, :behavior => :revoke, :destination_root => Rails.root diff --git a/railties/lib/rails/commands/generate.rb b/railties/lib/rails/commands/generate.rb index c5e3ae3529..c1120aad74 100755 --- a/railties/lib/rails/commands/generate.rb +++ b/railties/lib/rails/commands/generate.rb @@ -7,4 +7,4 @@ if ARGV.size == 0 end name = ARGV.shift -Rails::Generators.invoke name, ARGV, :behavior => :invoke +Rails::Generators.invoke name, ARGV, :behavior => :invoke, :destination_root => Rails.root diff --git a/railties/lib/rails/generators/base.rb b/railties/lib/rails/generators/base.rb index 5e8c2730fd..26abb46644 100644 --- a/railties/lib/rails/generators/base.rb +++ b/railties/lib/rails/generators/base.rb @@ -12,16 +12,6 @@ module Rails add_runtime_options! - # Always move to rails source root. - # - def initialize(*args) #:nodoc: - if !invoked?(args) && defined?(Rails.root) && Rails.root - self.destination_root = Rails.root - FileUtils.cd(destination_root) - end - super - end - # Automatically sets the source root based on the class name. # def self.source_root @@ -268,13 +258,6 @@ module Rails end end - # Check if this generator was invoked from another one by inspecting - # parameters. - # - def invoked?(args) - args.last.is_a?(Hash) && (args.last.key?(:invocations) || args.last.key?(:destination_root)) - end - # Use Rails default banner. # def self.banner