aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails/generators/base.rb
diff options
context:
space:
mode:
Diffstat (limited to 'railties/lib/rails/generators/base.rb')
-rw-r--r--railties/lib/rails/generators/base.rb9
1 files changed, 6 insertions, 3 deletions
diff --git a/railties/lib/rails/generators/base.rb b/railties/lib/rails/generators/base.rb
index 0b91e3223e..1d3c947cb0 100644
--- a/railties/lib/rails/generators/base.rb
+++ b/railties/lib/rails/generators/base.rb
@@ -20,6 +20,8 @@ module Rails
class_option :skip_namespace, type: :boolean, default: false,
desc: "Skip namespace (affects only isolated applications)"
+ class_option :skip_collision_check, type: :boolean, default: false,
+ desc: "Skip collision check"
add_runtime_options!
strict_args_position!
@@ -231,7 +233,7 @@ module Rails
# Invoke source_root so the default_source_root is set.
base.source_root
- if base.name && base.name !~ /Base$/
+ if base.name && !base.name.match?(/Base$/)
Rails::Generators.subclasses << base
Rails::Generators.templates_path.each do |path|
@@ -249,6 +251,7 @@ module Rails
# application or Ruby on Rails.
def class_collisions(*class_names)
return unless behavior == :invoke
+ return if options.skip_collision_check?
class_names.flatten.each do |class_name|
class_name = class_name.to_s
@@ -261,8 +264,8 @@ module Rails
if last && last.const_defined?(last_name.camelize, false)
raise Error, "The name '#{class_name}' is either already used in your application " \
- "or reserved by Ruby on Rails. Please choose an alternative and run " \
- "this generator again."
+ "or reserved by Ruby on Rails. Please choose an alternative or use --skip-collision-check " \
+ "to skip this check and run this generator again."
end
end
end