If you generate a model whose name ends with an underscore and then some numbers, Rails cannot then autoload the model's class.
As an example, if you generate a model with "$ rails g model monkey_100", this generates a file called monkey_100.rb containing a class called Monkey100. However, when you try to access Monkey100, Rails tries to find a file called monkey100.rb, and fails. The underlying reason for this is that String#underscore is not quite the functional inverse of String#camelize. String#camelize is used to determine the class name (see NamedBase#class_name in railties/lib/rails/generators/named_base.rb) while String#underscore is used to determine the file in which the constant is expected to be defined (see load_missing_constant in activesupport/lib/active_support/dependencies.rb). I think that Rails should check, when generating a model (and possibly other things), that the resulting class's name is autoloadable, and fail if not. If I were to provide a patch, is it likely to be accepted? Cheers, Peter. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
