Permalink
Browse files

Added better error message for when the class name is already used (a…

…nd dont show suggestions if there are none)
  • Loading branch information...
1 parent f701533 commit 9b75483bf361f44046d1cb86bd2acae6c4f856f3 @dhh dhh committed May 31, 2008
Showing with 5 additions and 3 deletions.
  1. +5 −3 railties/lib/rails_generator/commands.rb
@@ -380,12 +380,14 @@ def render_file(path, options = {})
# Thanks to Florian Gross (flgr).
def raise_class_collision(class_name)
message = <<end_message
- The name '#{class_name}' is reserved by Ruby on Rails.
+ 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.
end_message
if suggest = find_synonyms(class_name)
- message << "\n Suggestions: \n\n"
- message << suggest.join("\n")
+ if suggest.any?
+ message << "\n Suggestions: \n\n"
+ message << suggest.join("\n")
+ end
end
raise UsageError, message
end

1 comment on commit 9b75483

really nice job guys. appreciate what you are doing. if theres anything a ruby novice can do to help, let me know.

does this fix the issue when creating nested namespaces and controllers? for expample:
ruby script/generate controller Admin::Pages …. error … PagesHelper reserved name when pages_controller already exists outside of admin folder?
-thanks

Please sign in to comment.