Skip to content

Commit

Permalink
Added better error message for when the class name is already used (a…
Browse files Browse the repository at this point in the history
…nd dont show suggestions if there are none)
  • Loading branch information
dhh committed May 31, 2008
1 parent f701533 commit 9b75483
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions railties/lib/rails_generator/commands.rb
Expand Up @@ -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
Expand Down

1 comment on commit 9b75483

@ryanLonac
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.