aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--railties/guides/source/generators.textile12
-rw-r--r--railties/lib/rails/commands/destroy.rb1
-rwxr-xr-xrailties/lib/rails/commands/generate.rb1
-rw-r--r--railties/lib/rails/generators.rb8
-rw-r--r--railties/test/generators/generators_test_helper.rb7
5 files changed, 13 insertions, 16 deletions
diff --git a/railties/guides/source/generators.textile b/railties/guides/source/generators.textile
index d3757e9733..b77a2837c3 100644
--- a/railties/guides/source/generators.textile
+++ b/railties/guides/source/generators.textile
@@ -322,14 +322,10 @@ config.generators do |g|
g.template_engine :erb
g.test_framework :shoulda, :fixture => false
g.stylesheets false
-end
-</ruby>
-
-And at the end of the same file:
-<ruby>
-require 'rails/generators'
-Rails::Generators.fallbacks[:shoulda] = :test_unit
+ # Add a fallback!
+ g.fallbacks[:should] = :test_unit
+end
</ruby>
Now, if create a Comment scaffold, you will see that shoulda generators are being invoked, and at the end, they are just falling back to test unit generators:
@@ -361,7 +357,7 @@ $ rails generate scaffold Comment body:text
create test/unit/helpers/comments_helper_test.rb
</shell>
-Such tool allows your generators to have single responsibility, increasing the code reuse and reducing the amount of code duplication.
+Such tool allows your generators to have single responsibility, increasing the code reuse and reducing the amount of duplication.
h3. Changelog
diff --git a/railties/lib/rails/commands/destroy.rb b/railties/lib/rails/commands/destroy.rb
index 9023c61bf2..db59cd8ad9 100644
--- a/railties/lib/rails/commands/destroy.rb
+++ b/railties/lib/rails/commands/destroy.rb
@@ -1,4 +1,5 @@
require 'rails/generators'
+Rails::Generators.configure!
if [nil, "-h", "--help"].include?(ARGV.first)
Rails::Generators.help 'destroy'
diff --git a/railties/lib/rails/commands/generate.rb b/railties/lib/rails/commands/generate.rb
index 7d05a30de8..1b3eef504a 100755
--- a/railties/lib/rails/commands/generate.rb
+++ b/railties/lib/rails/commands/generate.rb
@@ -1,4 +1,5 @@
require 'rails/generators'
+Rails::Generators.configure!
if [nil, "-h", "--help"].include?(ARGV.first)
Rails::Generators.help 'generate'
diff --git a/railties/lib/rails/generators.rb b/railties/lib/rails/generators.rb
index fe8a6c0b94..af92757053 100644
--- a/railties/lib/rails/generators.rb
+++ b/railties/lib/rails/generators.rb
@@ -68,6 +68,7 @@ module Rails
options.deep_merge! config.options
fallbacks.merge! config.fallbacks
templates_path.concat config.templates
+ templates_path.uniq!
end
def self.templates_path
@@ -328,10 +329,5 @@ module Rails
paths.uniq!
paths
end
-
end
-end
-
-# If the application was already defined, configure generators,
-# otherwise you have to configure it by hand.
-Rails::Generators.configure! if Rails.respond_to?(:application) && Rails.application
+end \ No newline at end of file
diff --git a/railties/test/generators/generators_test_helper.rb b/railties/test/generators/generators_test_helper.rb
index d8bdb344f2..4a5a9b2932 100644
--- a/railties/test/generators/generators_test_helper.rb
+++ b/railties/test/generators/generators_test_helper.rb
@@ -1,4 +1,6 @@
require 'abstract_unit'
+require 'rails/generators'
+require 'rails/generators/test_case'
module Rails
def self.root
@@ -8,8 +10,9 @@ end
Rails.application.config.root = Rails.root
Rails.application.config.generators.templates = [File.join(Rails.root, "lib", "templates")]
-require 'rails/generators'
-require 'rails/generators/test_case'
+# Call configure to load the settings from
+# Rails.application.config.generators to Rails::Generators
+Rails::Generators.configure!
require 'active_record'
require 'action_dispatch'