aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails/generators.rb
diff options
context:
space:
mode:
Diffstat (limited to 'railties/lib/rails/generators.rb')
-rw-r--r--railties/lib/rails/generators.rb11
1 files changed, 8 insertions, 3 deletions
diff --git a/railties/lib/rails/generators.rb b/railties/lib/rails/generators.rb
index 8ec805370b..6c9c109f17 100644
--- a/railties/lib/rails/generators.rb
+++ b/railties/lib/rails/generators.rb
@@ -1,4 +1,6 @@
-activesupport_path = File.expand_path("../../../../activesupport/lib", __FILE__)
+# frozen_string_literal: true
+
+activesupport_path = File.expand_path("../../../activesupport/lib", __dir__)
$:.unshift(activesupport_path) if File.directory?(activesupport_path) && !$:.include?(activesupport_path)
require "thor/group"
@@ -10,6 +12,7 @@ require "active_support/core_ext/kernel/singleton_class"
require "active_support/core_ext/array/extract_options"
require "active_support/core_ext/hash/deep_merge"
require "active_support/core_ext/module/attribute_accessors"
+require "active_support/core_ext/string/indent"
require "active_support/core_ext/string/inflections"
module Rails
@@ -215,6 +218,7 @@ module Rails
rails.delete("app")
rails.delete("plugin")
rails.delete("encrypted_secrets")
+ rails.delete("credentials")
hidden_namespaces.each { |n| groups.delete(n.to_s) }
@@ -270,8 +274,9 @@ module Rails
else
options = sorted_groups.flat_map(&:last)
suggestions = options.sort_by { |suggested| levenshtein_distance(namespace.to_s, suggested) }.first(3)
- msg = "Could not find generator '#{namespace}'. "
- msg << "Maybe you meant #{ suggestions.map { |s| "'#{s}'" }.to_sentence(last_word_connector: " or ", locale: :en) }\n"
+ suggestions.map! { |s| "'#{s}'" }
+ msg = "Could not find generator '#{namespace}'. ".dup
+ msg << "Maybe you meant #{ suggestions[0...-1].join(', ')} or #{suggestions[-1]}\n"
msg << "Run `rails generate --help` for more options."
puts msg
end